Вы находитесь на странице: 1из 140

MA113:

LOGIC AND DISCRETE MATHEMATICS


W. R. Johnstone
AUTUMN: 2004
REFERENCES:
[1] Introductory Logic and Sets for Computer Scientists: N. Nissanke: Addi-
son Wesley Longman: 004.015113
[2] Logic (Schaums Outline Series): J. Nolt and D. Rohatyn: FOLIO-160-
NOL
[3] Set Theory and Related Topics (Schaums Outline Series): S. Lipschutz:
FOLIO-511.322-LIP
[4] Discrete Mathematics: (Schaums Outline Series): S. Lipschutz and M. L.
Lipson: FOLIO-510-LIP
[5] Discrete Mathematics with Applications: S. S. Epp: 510-EPP
[6] Introduction to Discrete Mathematics and Formal System Specication:
D. C. Ince: Oxford: 004.0151-INC
[7] The Z Notation: J. M. Spivey: Prentice-Hall: 005.133-Z/SPI
[8] Sets, Logic and Axiomatic Theories: R. R. Stoll: Freeman: 517.1
[9] Set Theory and Logic: R. R. Stoll: 511.322-STO
[10] The Essence of Logic: J. J. Kelly: Prentice Hall: 511.3-KEL
[11] Introduction to Symbolic Logic: A. H. Basson: 511.3-BAS
[12] Introduction to Symbolic Logic: S. K. Langer: 511.3-LAN
[13] Logic and its Applications: E. Burke: 511.3-BUR
[14] Mathematical Logic for Computer Science: M. Ben-Ari: 511.3-BEN
[15] Modern Logic : a text on Elementary Symbolic Logic: G. Forbes: 511.3-
FOR
[16] Symbolic Logic: I. M. Copi: 160-COP
[17] Symbolic Logic: R. H. Thomason: 511.3-THO
[18] Elementary Set Theory: K-T. Leung and D. L-C Chen: 511.322-LEU
[19] Set Theory (Schaums Outline Series): S. Lipschutz: FOLIO517.1-LIP
Contents
1 PROPOSITIONAL LOGIC 1
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Propositions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Connectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 The connective . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5 The Connective . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.6 The Connective . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.7 The Connective = . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.8 The Connective . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.9 Truth Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.10 Brackets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.11 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.12 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.13 Applications to Computer Science . . . . . . . . . . . . . . . . . 8
1.14 Truth Tables in General . . . . . . . . . . . . . . . . . . . . . . . 9
1.15 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.16 Logical Equivalence . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.17 Denition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.18 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.19 Solution to Exercise 1.15 . . . . . . . . . . . . . . . . . . . . . . . 12
1.20 Denition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.21 Tautologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.22 Denition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.23 Contradictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.24 Denition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.25 The Propositions True and False . . . . . . . . . . . . . . . . . . 14
1.26 Logical Laws . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.27 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.28 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.29 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.30 Inference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.31 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.32 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.33 The Method of Formal Proof . . . . . . . . . . . . . . . . . . . . 22
1.34 Inference Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.35 Formal Proofs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
1.36 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
1.37 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
i
1.38 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
1.39 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
1.40 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
1.41 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2 PREDICATE LOGIC 31
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.2 Predicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.3 Inx Notation for Binary Predicates . . . . . . . . . . . . . . . . 33
2.4 The Binary Predicates <, , >, and = . . . . . . . . . . . . . 33
2.5 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.6 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.7 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.8 Quantiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.9 Restricted Quantiers . . . . . . . . . . . . . . . . . . . . . . . . 37
2.10 The Scope of a Quantier . . . . . . . . . . . . . . . . . . . . . . 40
2.11 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.12 Multiple Quantiers . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.13 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.14 Variables and Constants . . . . . . . . . . . . . . . . . . . . . . . 46
2.15 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3 PROOF BY INDUCTION 52
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.2 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
3.3 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.4 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.5 WARNING . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.6 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.7 Generalizations of Proof by Induction . . . . . . . . . . . . . . . 58
3.8 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4 BASIC SET THEORY 60
4.1 Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.2 The Universal Set . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.3 Subsets of a Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.4 Vacuous Truth . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.5 Set Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.6 Venn Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.7 Disjoint Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.8 Cardinality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.9 Sets of Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.10 The Power Set of a Set . . . . . . . . . . . . . . . . . . . . . . . . 72
4.11 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.12 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.13 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.14 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
ii
5 RELATIONS 78
5.1 Ordered Pairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.2 Equality of Ordered Pairs . . . . . . . . . . . . . . . . . . . . . . 78
5.3 Cartesian Product of Sets . . . . . . . . . . . . . . . . . . . . . . 79
5.4 Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5.5 Relations on a Set . . . . . . . . . . . . . . . . . . . . . . . . . . 80
5.6 Domain and Range of a Relation . . . . . . . . . . . . . . . . . . 81
5.7 The Inverse of a Relation . . . . . . . . . . . . . . . . . . . . . . 82
5.8 Relational Image . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
5.9 Restrictions of Relations . . . . . . . . . . . . . . . . . . . . . . . 84
5.10 Set Operations on Relations . . . . . . . . . . . . . . . . . . . . . 85
5.11 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
5.12 Relational Overriding . . . . . . . . . . . . . . . . . . . . . . . . 87
5.13 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
5.14 Composition of Relations . . . . . . . . . . . . . . . . . . . . . . 89
5.15 The Directed Graph of a Relation on a Set . . . . . . . . . . . . 92
5.16 The Relation R
2
. . . . . . . . . . . . . . . . . . . . . . . . . . . 93
5.17 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
5.18 The Relation R
3
. . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.19 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.20 The Relations R
n
for a natural number n . . . . . . . . . . . . . 96
5.21 Non-Mathematical Example . . . . . . . . . . . . . . . . . . . . . 98
5.22 Properties of Relations . . . . . . . . . . . . . . . . . . . . . . . . 99
5.23 Partitions of a Set . . . . . . . . . . . . . . . . . . . . . . . . . . 103
5.24 Equivalence Relations . . . . . . . . . . . . . . . . . . . . . . . . 104
5.25 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
6 FUNCTIONS 109
6.1 Total and Partial Functions . . . . . . . . . . . . . . . . . . . . . 109
6.2 Injective Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 111
6.3 Surjective Functions . . . . . . . . . . . . . . . . . . . . . . . . . 114
6.4 Bijective Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 116
6.5 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
6.6 Functions as Operators or Procedures . . . . . . . . . . . . . . . 119
6.7 Relational Images of Functions . . . . . . . . . . . . . . . . . . . 119
6.8 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
6.9 Functions Dened by Formulae . . . . . . . . . . . . . . . . . . . 123
6.10 Composition of Functions . . . . . . . . . . . . . . . . . . . . . . 123
6.11 Number Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
6.12 Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
6.13 Operations on Sequences . . . . . . . . . . . . . . . . . . . . . . . 127
6.14 Functional Overriding . . . . . . . . . . . . . . . . . . . . . . . . 128
6.15 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
6.16 Bags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
6.17 Operations on Bags . . . . . . . . . . . . . . . . . . . . . . . . . . 133
iii
Chapter 1
PROPOSITIONAL LOGIC
1.1 Introduction
In Mathematics and Computer Science we need to express statements in a very
precise and unambiguous way, leaving no doubt as to what is meant. This
requires a form of language which is more rigid and structured than that used
in everyday life. In this chapter we will begin the development of such a language
from quite a basic level.
We will rst consider various ways of constructing statements. We start with
fairly simple statements such as:
A: It is raining,
B: The sun is shining;
and create such compound statements as:
[1] A or B,
i.e. it is raining or the sun is shining,
[2] A and B,
i.e. it is raining and the sun is shining,
[3] not A,
it is not raining,
[4] if A then not B,
if it is raining then the sun is not shining.
Propositional Logic is the study of such processes and related deductive reason-
ing using symbols to represent the basic objects of the study.
1.2 Propositions
A proposition or statement is a sentence which asserts something that is either
true or false. Such a statement must have a precise and unambiguous meaning
so that its truth or falsity can denitely be decided. Thus all propositions have
an assigned truth value; T, when the proposition is true, and F, when the
proposition is false. The following sentences are propositions:
1
It is snowing.
It is not cloudy.
2 + 2 = 4.

2 is an integer.
However the following sentences or phrases are not propositions:
Do you like kippers?
If you pass go, collect 200.
A pot of gold.
A simple statement which links two objects is often called an atomic statement.
Atomic statements will be represented symbolically by a letter such as A or
by a letter with a numerical subscript such as A
5
. Such a symbol (or symbols)
used in this way will be called a propositional letter. An atomic statement itself
has a symbolic form often of the type a x b, where a,b are phrases which
represent the objects and x is a phrase which represents the link. For example
if a x b represents the atomic statement ve is greater than three then a
represents the number ve, b represents three and x represents the linking
phrase is greater than.
1.3 Connectives
The following symbols, known as connectives, are used to build up more compli-
cated propositions from simpler ones. We may start the building process with
atomic propositions:
Connective Approximate English Translation Name
not Negation
and Conjunction
or Disjunction
implies
= OR Implication
if . . . then
implies and is implied by
OR
if and only if Equivalence
OR
is equivalent to
The right hand column is headed approximate English translation because
English words are often used loosely and inconsistently. In order to properly
dene the logical connectives in this table, we will have to impart a precise and
unambiguous meaning to the equivalent words and phrases.
1.4 The connective
From any proposition P we can form a new proposition P (pronounced not
P). For example, if P is the proposition The sun is shining then P is the
2
proposition The sun is not shining (or any form of words that has the same
meaning). P asserts that P is false. Indeed if P is true, then P is false, but,
if P is false, then P is true. P is sometimes called the negation of P. Given a
proposition P there are usually many ways of expressing the proposition P in
words; we attempt to choose a representation which feels right, i.e. one which
is widely regarded as acceptable. For example, if P is the statement The bus
is not red, then the statement The bus is red is a more acceptable form for
P than The bus is not not red. Note that a double negative is often used
incorrectly in colloquial English. For example if P is the proposition Trac
lights are never blue, then P is sometimes incorrectly expressed as Trac
lights are not never blue. This latter sentence is really the negation, P, of P.
A double negation is probably used in the belief that the extra not emphasizes
the negation.
1.5 The Connective
From two propositions A and B we can form a new proposition A B (pro-
nounced A and B). For example, if A is the proposition 2 + 2 = 4 and B
is the proposition

2 is an integer, then A B is the proposition 2 + 2 = 4


and

2 is an integer. A B is true when A and B are both true, and is false
otherwise. Thus A B asserts that A and B are both true.
1.6 The Connective
From two propositions A and B we can form a proposition A B (pronounced
A or B). For example, if A and B are the propositions stated in the previous
section, then A B is the proposition 2 +2 = 4 or

2 is an integer. The use
of the word or in this context must be made more precise than the ordinary
use of the word in the English language. In language it may be used in both an
inclusive and an exclusive sense. In our context we use it in the inclusive sense.
Thus A B asserts that one or both of the statements A,B are true. It does
NOT assert that one and only one of these statements are true (the exclusive
case)
1
. Thus A B is false only when both A and B are false; in all the other
cases AB is true. The symbol has the meaning conveyed by and/or which
is sometimes used in written English.
1.7 The Connective =
From two propositions A and B we can form a new proposition A = B (pro-
nounced A implies B). The meaning of A = B is roughly that of if A then
B. Thus A = B is a proposition which asserts that if A is true then B is
also true. If on the other hand A is false then B could be either true or false.
Thus A = B asserts that either A is false or B is true (or both); i.e. (A) B
is true. We may therefore dene the connective = by saying that A = B
means the same thing as (A) B. Note that A does not have to be true for
1
In ordinary language I may assert that I shall have a kipper for lunch or I shall have a
pork pie for lunch, with or used in an exclusive sense (to mean that I shall have either a
kipper or a pork pie, but NOT both, for lunch).
3
A = B to be true. The only way for A = B to be false is for A to be true
and B to be false. Thus the following are true statements:
[1] 2 + 2 = 4 = 2
2
= 4;
[2] 2 + 3 = 4 = 2
2
= 4;
[3] 3 + 2 = 4 = 2
2
= 3.
whilst the following statement is false:
2 + 2 = 4 = 2
2
= 3.
1.8 The Connective
From two propositions A and B we may form a new Proposition A B
(pronounced A implies B and is implied by B or A if and only if B or A
is equivalent to B). The proposition A B asserts that both A = B and
B = A are true propositions. It is easy to verify that A B asserts that
either both A and B are true or both are false. Thus the propositions:
2 + 2 = 4 2
2
= 4;
2 + 3 = 4 2
2
= 3;
are both true, whereas the propositions:
2 + 2 = 4 2
2
= 3;
2 + 3 = 4 2
2
= 4;
are both false.
1.9 Truth Tables
If a proposition is true, we say that it has truth value T, whereas, if the
proposition is false, we say that it has truth value F. Thus every proposition
has a truth value. For example 2 +2 = 4 has truth value T and 2
2
= 3 has
truth value F.
We can assign a truth table to any formal compound statement which
involves only symbols for atomic statements and the symbols which represent
connectives. The table gives the resultant truth value for the compound state-
ment for every possible truth value assignments to the atomic statements. Thus
the truth table for the proposition A is:
A A
T F
F T
The table indicates that A has truth value F when A has truth value T and
A has truth value T when A has truth value F.
Let us consider the truth table for the proposition A B. There are four
dierent ways to assign truth values to A and B. A B is only true in one of
these four cases; namely when A and B are both true. Thus the truth table for
A B is:
4
A B A B
T T T
T F F
F T F
F F F
Recall that the proposition A B is true when one or both A,B are true.
Thus A B has the truth value F only when both A and B have truth value
F. Thus the truth table of A B is:
A B A B
T T T
T F T
F T T
F F F
Again recall that A = B is false only when A is true and B is false. Thus
A = B has truth value T in all cases except when A has truth value T and B
has truth value F in which case it has truth value F. Thus the truth table for
A = B has truth table:
A B A = B
T T T
T F F
F T T
F F T
Finally recall that A B is true only when A and B are both true or
both false. It follows that A B has truth table:
A B A B
T T T
T F F
F T F
F F T
1.10 Brackets
Given atomic statements A,B and C, can we assign a meaning to the sentence
A B C? We may pronounce this sentence as A or B and C. However
there appears to be some ambiguity about what is meant here. The ambiguity
becomes somewhat clearer if we use punctuation: A or B, and C, or A,
or B and C. The ambiguity arises from the order in which we apply the
connectives to form the compound statement. To clarify the order in which the
connectives are applied we will use brackets
2
. Thus we may write (AB) C
or A (B C). For example (A B) C is formed by rst applying the
connective to A and B and then applying the connective to A B and C.
The proposition A(BC) is obtained in the same way by reversing the order
in which these connectives are applied. To emphasize the distinction between
the statements let us consider their truth values. Suppose that A and B are
2
Brackets are used in this way in arithmetic and algebra. Thus for example 3 + (2 4)
means 3 + 8, which equals 11, whereas (3 + 2) 4 means 5 4, which equals 20
5
true and C is false. Then (AB) C is clearly false, since C is false. However
A (B C) is clearly true, since A is true. Thus the statements cannot be
considered the same since they have dierent truth values when A and B are
true and C is false. To recap, with proper use of brackets, compound statements
can be made logically precise (i.e. without any ambiguity).
Similarly (A B) is dierent from (A) B. When A and B are false,
(A B) is true whereas (A) B is false.
The use of brackets can become rather cumbersome when dealing with propo-
sitions which involve very many connectives. To simplify the expression of such
statements we will employ a convention concerning an order of precedence of
connectives
3
. We arrange connectives in the following order of precedence:
= . Thus for example we apply the connective before and before
. The following examples illustrate the use of the convention:
[1] A B C means (A B) C;
[2] A B means (A) B;
[3] AB = CDE means ((A)B) = ((CD)E). The connectives
are performed in their order of precedence. Thus we rst apply to A
to obtain A. The next connective to apply is to obtain the statement
C D. Next we apply the connective . There are two instances of this
connective in the proposition. Thus we form the two statements (A) B
and (C D) E. Finally we apply the connective = to complete the
proposition. Note that at each stage in this process brackets are used
to bound each of the two statements which are joined by the connective
used. We need not use brackets to bound the nal proposition. Each
opening bracket, (, must be paired with a closing bracket, ), so that they
both bound a complete syntactically correct statement. [It may help in
reading a complicated proposition with many brackets if we use a counting
procedure. We count the number of opening brackets encountered which
have not been paired o with the associated closing bracket. We will
refer to this number as the level. For example we begin at level 0 and on
encountering the rst opening bracket we are at level 1. If in parsing along
an expression we encounter an opening bracket which begins level n, say,
then its associated closing bracket is the rst closing bracket at the same
level, n, which is reached as we continue to parse along the expression.]
[4] A(BC = D) E G means ((A((BC) = D)) E) G.
Note that the convention on precedence will not allow us to remove the
brackets binding the statement B C = D. The proposition A B
C = DE G means (((AB)C) = (DE)) G, which is not
the same as the proposition ((A((BC) = D))E) G. The rules
on precedence will perhaps allow the removal of many but not all brackets
without changing the meaning of a proposition. Also we will sometimes
leave removable brackets in place if it makes it easier to interpret the
proposition.
3
A similar convention is used to order the arithmetic operations. For example we write
3 +2 4 to mean 3 +(2 4). We say that multiplication () takes precedence over addition
(+); that is multiplication is performed before addition.
6
1.11 Exercise
Given statements A and B. Using only the connectives and is it possible
to construct from A and B a proposition P with truth table:
A B P
T T F
T F T
F T F
F F T
Given any such truth table (there are 16 dierent tables), is it possible to con-
struct a proposition P with that truth table?
1.12 Worked Example
Translate the following English sentences into propositional logic, using the
letters A for the sun shines, B for the game of football takes place, C for
the game of hockey takes place and D for it is raining.
[1] If the sun shines then the game of football will take place.
[2] The games of football and hockey will both take place if the sun shines.
[3] Either the game of football or the game of hockey but not both will take
place.
[4] If the sun does not shine then the game of football or the game of hockey
will be cancelled.
[5] If the game of hockey is cancelled then the decision on whether to play
the game of football will depend on whether it is raining.
Solution. As this illustrates, spoken and written English uses many forms of
words, and one must think carefully what they mean when translating them into
the precise language of propositional logic. Sometimes English words might be
so ambiguous that their intended meaning is uncertain, and consequently one
can only oer two or more possible translations. If this arose in practice, one
would presumably ask the person concerned to clarify what is actually meant.
Let us now attempt to translate the above sentences.
[1] This says that if A then B or (in other words) A implies B. Thus, in
propositional logic, it is the proposition A = B.
[2] Do not be deceived by the word order in this sentence. The statement is
just another way of saying If the sun shines then the games of football and
hockey will both take place or more clumsily If the sun shines then the
game of football will take place and the game of hockey will take place.
It follows that the translation is A = (B C), or, using the convention
on ordering, A = B C.
7
[3] This might require some thought. The words but not is eectively the
same as and not. The word but is used to contrast the two connecting
statements and means the same as on the other hand. It is used in the
same conjunctive sense as the word and and not in the disjunctive sense
of the word or. Thus the given statement may expressed in the form
Either the game of football takes place or the game of hockey takes place
and the games of football and hockey do not both take place. This
translates to (B C) ((B C)). Note that the statement the games
of football and hockey do not both take place is the negation of the
statement the games of football and hockey both take place. The given
statement may also be translated in other ways. The statement may be
expressed in the form the game of football takes place but not the game
of hockey, or the game hockey takes place but not the game of football.
this statement translates to (BC)(CB). The given statement may
also be expressed in the form precisely one and only one of the games of
football and hockey takes place. This means that the game of football
takes place if and only if the game of hockey does not take place. Thus
the statement also translates to B C. Yet another translation (by
symmetry) is B C. Note that all these translations have the same
truth table. This example illustrates the use of the exclusive or in English.
[4] It is not clear in this context whether the word or is used in the inclusive
or exclusive sense. When or is used in the exclusive sense, then the
statement may be expressed as if the sun does not shine then one of the
games of football and hockey take place and the other does not. This
translates to A = (B C) (C B). As for the previous example
there are other translations. When or is used in the inclusive sense the
analysis is much simpler. A translation is clearly A = (B C).
Another translation might be A = (B C). Yet another translation
which requires more thought is (BC) = A. The last two are not really
direct translations since they involve some logical reasoning.
[5] Again it is not absolutely clear what is meant by the decision on whether
to play the game of football will depend on whether it is raining. Presum-
ably it means the game of football will take place if and only if it is not
raining, i.e. B D. [It is possible, but not very likely, that the state-
ment means the game of football will take place if and only if it is rain-
ing.] Therefore the given statement translates to C = (B D).
1.13 Applications to Computer Science
Computer programs in whatever language require a precise structure. Just as a
proposition in logic must have an unambiguous meaning, lines in a program must
have an unambiguous meaning according to precise formal rules. A common
structure in most computer languages is a statement of the form if A then B.
Indeed a computer is an ideal machine for applying the rules of logic. A true
statement can be given the value 1 and a false statement the value 0. The
rules and structures of logic can be translated into an algebra, called Boolean
Algebra, with 0 and 1 as the only numbers. The computer is able to make
use of this algebra to decide upon the truth value of a proposition.
8
Also Formal Logic is a useful tool in the development of computer programs.
For example, suppose that a computer database contains a list of certain people
and their telephone numbers. We may require a short program to inform us
of the telephone number of a particular person which we input. We may also
want the computer to inform us if the person is not stored in the database. To
construct the program we must rst consider the logistics of it. What is the
precise logical requirement of the program? We rst input a persons name, say
John Smith. The computer reads the name and compares it to the names
in the database. If the name is found it outputs the corresponding telephone
number. If the name is not found it outputs an appropriate message, say This
persons telephone number is not known. Let us construct the proposition
that the program is asserting. Let A be the statement We input John Smiths
name, let B be the statement John Smiths name is in the database, let C
be the statement The output is John Smiths telephone number and let D
be the statement The output is not known. The essential feature of the
program is that on receiving an input the computer will give an output. This
can be expressed in the form If P then Q; i.e. P = Q. It is clear that in
this context P = A; i.e. P is the statement A. There are two alternatives for
the output. If B then C. On the other hand if B then D. Thus Q must be the
statement (B = C) (B = D). Thus the program asserts the proposition
A = ((B = C)(B = D)). This particular program is very simple and so
the above analysis may seem unnecessarily pedantic. However there are many
programs that are much more complicated and an analysis of the type used
here is extremely useful in developing good programming techniques. Indeed
the material in this course forms a foundation for Formal Methods in Computer
Science [See J. M. Spivey - The Z Notation (A Reference Manual) - Prentice
Hall.].
1.14 Truth Tables in General
Using the truth tables for the connectives, we can construct truth tables for
compound statements. For example a truth table for the proposition P which
asserts (A = C) = ((A B) C) would tell us the truth value of this
proposition when we know the truth value of A, B and C. The truth value of
the proposition can be determined in stages by nding the truth values of the
statements A = C, AB and (AB) C before nally using the truth table
for =. The whole process may be tabulated as follows:
A B C A = C A B (A B) C P
T T T T T T T
T T F F T F T
T F T T T T T
T F F F T F T
F T T T T T T
F T F T T F F
F F T T F F F
F F F T F F F
In the rst three columns we list all the 8 possible truth values for A, B and
C. We use the truth table for = and the truth values in columns 1 and 3 to
9
enter in column 4 the truth values for A = C. We use the table for and
the truth values in columns 1 and 2 to enter in column 5 the truth values for
AB. We use the table for and the truth values in columns 3 and 5 to enter
in column 6 the truth values of (A B) C. Finally we enter the truth values
for the whole proposition P in column 7 using the table for = and the truth
values in columns 4 and 6.
Note that we can economize in the lling in of the table with truth values.
For example, if A = C is false, then P is true whatever the truth value of
(A B) C. In this case we do not need to enter truth values for A B and
(AB) C. Similarly, if C is false, then (AB) C is necessarily false. Thus
the truth table may be constructed as follows:
A B C A = C A B (A B) C P
T T T T T T T
T T F F T
T F T T T T T
T F F F T
F T T T T T T
F T F T F F
F F T T F F F
F F F T F F
1.15 Exercise
Work out truth tables for:
[1] (A = B) (A B);
[2] (A = C) (C = C B).
Attempt this for yourselves and then compare your answer with the one given
later in section 1.19.
1.16 Logical Equivalence
In ordinary English, there may be two or more dierent ways of saying the same
thing. The same is true of the propositional logic. For example recall that in
section 1.12 the statement Either the game of football or the game of hockey
but not both will take place had the three translations (B C) (B C),
(BC)(CB) and B C. Indeed these propositions all have the same
truth values whatever the truth values of B and C. This fact can be conrmed
from the following truth tables:
B C B C B C (B C) (B C) (B C)
T T T T F F
T F T F T T
F T T F T T
F F F F T F
10
B C C B C B C B (B C) (C B)
T T F F F F F
T F T T F F T
F T F F T T T
F F T F T F F
B C C B C
T T F F
T F T T
F T F T
F F T F
Since these three truth tables have the same truth values in the last column,
the propositions (BC) (BC), (BC) (C B) and B C have
the same truth value in every possible case. We express this by saying that the
three propositions are logically equivalent.
1.17 Denition
Two propositions are said to be logically equivalent if they have the same truth
values for each possible assignment of truth values to the proposition letters
which occur in them. If proposition A is logically equivalent to proposition
B, we write A B. is not a logical connective in the sense of the
other connectives, since it is to be used only when the propositions are logically
equivalent. Its usage is incorrect if the propositions are not logically equivalent.
It is used mainly in demonstrations or proofs that two given statements are
logically equivalent. The sentence A B is not a statement in Propositional
Logic.
For example the proposition letters occurring in the propositions (B C)
(BC) and B C are B and C. Since, for every assignment of truth values
to B and C, the two propositions have the same truth value, (BC) (BC)
and B C are logically equivalent. In this case we are justied in writing
(B C) (B C) B C. Note that in such sentences we do not
need to delimit with brackets each of the two propositions which are connected
by . We may assume that has the least order of priority amongst all
the connectives.
1.18 Example
Prove that two of the three propositions:
A = B C;
A (A = B C);
(A C) B;
are logically equivalent.
Solution. The truth tables for these propositions are:
11
A B C C B C A = B C
T T T T T
T T F T T
T F T F F F
T F F T T T
F T T T
F T F T
F F T T
F F F T
A B C A B C A = B C A (A = B C)
T T T F T T
T T F F T T
T F T F T T
T F F F T T
F T T T T T F
F T F T T T F
F F T T T T F
F F F T F F T
A B C A C (A C) (A C) B
T T T T
T T F T
T F T T F F
T F F F T T
F T T T
F T F T
F F T F T T
F F F F T T
We conclude that the propositions A = BC and (AC) B are logically
equivalent, because their truth tables have the same arrangement of truth values
in the last column. Note that we have omitted entries in these truth tables which
are not needed in the calculation of the truth value in the last column.
1.19 Solution to Exercise 1.15
[1] The truth table is:
A B A B A = B (A = B) (A = B) (A B)
T T T T
T F F F T T
F T F T F F
F F F T F F
[2] Note that C = C B means C = (C B). Therefore denoting the
proposition (A = C) (C = C B) by P we require the truth table:
12
A B C A = C C B C = C B P
T T T T T T T
T T F F F
T F T T F F F
T F F F F
F T T T T T T
F T F T T T
F F T T F F F
F F F T T T
1.20 Denition
A tautology is a proposition which is always true whatever truth values are
assigned to the proposition letters which occur in it.
1.21 Tautologies
One might regard a tautology as a proposition which is self-evidently true just
by analysing its form. For example AA is a tautology; it asserts that either
A is true or A is false and this is clearly true of any statement, by denition.
Also AB = A is a tautology. This proposition can only be false when AB
is true and A is false. However AB cannot be true when A is false. Thus the
proposition must always be true.
A more complicated tautology is the proposition AB = (C = A). The
truth table for this proposition is:
A B C A B C = A A B = (C = A)
T T T T T T
T T F T T T
T F T F T
T F F F T
F T T F T
F T F F T
F F T F T
F F F F T
Since all the entries in the last column are T, the proposition is a tautology. Note
that, when AB is false, the proposition AB = (C = A) is automatically
true whatever the truth value of C = A, which therefore need not be entered
into the table.
1.22 Denition
A contradiction is a proposition which is always false, regardless of the truth
values assigned to the proposition letters which occur in it.
1.23 Contradictions
From the truth table for the connective we obtain the truth table for AA:
13
A A A A
T F F
F T F
Hence, by denition, A A is a contradiction. Note that this proposition is a
contradiction regardless of what A stands for.
To decide whether a given proposition is a contradiction it suces to build
its truth table. If the last column consists entirely of the truth value F, then
the proposition must be a contradiction. For example the truth table for B
(A = B) is:
A B A = B (A = B) B (A = B)
T T T F F
T F F
F T T F F
F F F
Therefore, since the truth value in the nal column of this table is always F,
the proposition B (A = B) is a contradiction.
1.24 Denition
A proposition is said to be a contingent proposition if it is neither a tautology
nor a contradiction. Such a proposition is contingent on the truth values of the
propositional letters which occur in it.
1.25 The Propositions True and False
The word True, when printed in italics, denotes the xed, but unspecied,
proposition which is always true. If you are unhappy with this denition, you
might x some specied tautology, say AA, or some true statement, say 0 =
0 and denote it by True. Similarly let False denote a xed, but unspecied,
proposition which is always false.
1.26 Logical Laws
There are a number of important rules, known as logical laws, which list certain
pairs of propositions that are logically equivalent. To be precise, the following
rules hold for any choice of statements A, B and C:
Commutative Laws
(I) A B B A.
(II) A B B A.
(III) A B B A.
Associative Laws
(IV) (A B) C A (B C).
14
(V) (A B) C A (B C).
Distributive Laws
(VI) A (B C) (A B) (A C).
(VII) A (B C) (A B) (A C).
De Morgans Laws
(VIII) (A B) A B.
(IX) (A B) A B.
Law of Negation
(X) A A.
Law of Implication
(XI) A = B A B.
Contrapositive Law
(XII) A = B B = A.
Law of Excluded Middle
(XIII) A A True.
Law of Contradiction
(XIV) A A False.
Law of Equivalence
(XV) A B (A = B) (B = A).
Laws of Idempotence
(XVI) A A A.
(XVII) A A A.
Laws of Simplication
(XVIII) A True A.
(XIX) A False False.
(XX) A True True.
(XXI) A False A.
(XXII) A (A B) A.
(XXIII) A (A B) A.
15
Most of these laws are self evident. Some may require a little more thought.
For instance, A (B C) asserts that A and at least one of B and C are
true. This means that A, B constitute a pair of true statements and/or A, C
constitute a pair of true statements. In other words AB is true and/or AC
is true; i.e. (AB) (AC) is true. Thus A(BC) and AB) (AC) are
two dierent ways of saying the same thing and hence are logically equivalent.
Of course one can construct truth tables to justify these laws. It is a good
learning exercise to carefully verify each of the above logical laws using one or
both of the methods just considered.
Rather than using truth tables to demonstrate the logical equivalence of two
propositions, we may apply the logical laws directly. The use of the laws may
also be much more economical. For example, applying rule (IX) with A taken
to be P = Q and B to be RS, ((P = Q) (RS)) is logically equivalent
to (P = Q) (R S). Thus we may write:
((P = Q) (R S)) (P = Q) (R S) (De Morgan)
Note that the label De Morgan means that one of De Morgans laws, namely
law (IX), has been applied. Similarly we may write:
((P = Q) (R = S)) ((P = Q) (R S)) (implication)
Here the label implication signies that the Law of Implication, rule (XI), has
been applied. We often verify that two propositions are logically equivalent by a
succession of steps like the above, applying one of the logical laws at each step.
The following worked examples illustrate the general technique.
1.27 Worked Example
Use logical laws to show that A = B C and (A C) B are logically
equivalent.
Solution.
A = B C A (B C) (implication)
A (C B) (commutativity)
(A C) B (associativity)
(A C) B (De Morgan)
Remark. Since the law of implication is the main logical law which expresses
the connective = in terms of the other connectives, it seems natural to use it
to transform A = BC into something a bit more like (AC) B. Indeed
we obtain A = BC A(BC). Similarly it is clear that, using one
of De Morgans laws, (AC) B can be expressed in terms of the statements
A, B and C. The remaining steps in the argument are a trivial consequence
of this observation. This method of working on both propositions (not just
one of them) to formulate a succession of steps which link them together, is a
very important technique for this type of problem. The context in which the
labels associativity and commutativity are used should clarify which of the
Associative or Commutative Laws are being applied.
16
1.28 Worked Example
Use logical laws to show that A = (B = C) is logically equivalent to (A =
B) = (A = C).
Solution. This is perhaps somewhat harder than the previous example. How-
ever the rst step is again to remove the connective = from both statements
and then to formulate a strategy to link the resulting statements. The follow-
ing argument is just one way to proceed (Note that there may be alternative
arguments):
(A = B) = (A = C) (A = B) (A = C) (implication)
(A B) (A C) (implication)
((A B) A) C (associativity)
((A B) A) C (De Morgan)
(A (A B)) C (commutativity)
((A A) (A B)) C
(distributivity)
(True (A B)) C (excluded middle)
((A B) True) C (commutativity)
(A B) C (simplication)
A (B C) (associativity)
A (B = C) (implication)
A = (B = C) (implication)
Remark. Sometimes it is a little easier to change the order of the two propo-
sitions. In this case the argument starts with the statement (A = B) =
(A = C), since this statement appears more complicated than the other state-
ment. The labels in brackets after each step indicates the type of law used to
justify the step, and hence we call these labels justications. Note that we must
apply the logical laws as stated and not make up our own laws or extensions to
given laws. For instance in the above argument we cannot apply the appropriate
Law of Simplication (rule (XVIII)) to the statement (True (A B)) C
directly, without rst using commutativity to put the statement True in the
right position. Otherwise we must add to the logical laws the additional cases
needed. The consequent increase in the number of such laws is both large and
unnecessary. A more interesting idea is to decide on as few laws as is necessary
to demonstrate all logical equivalences.
17
1.29 Worked Example
Fill in the justications for each step in the following argument:
(A = C) (B = C) (A C) (B C)
(C A) (C B)
C (A B)
C (A B)
(A B) C
(A B) = C
(A B) = C
Solution.
(A = C) (B = C) (A C) (B C) (implication)
(C A) (C B) (commutativity)
C (A B) (distributivity)
C (A B) (De Morgan)
(A B) C (commutativity)
(A B) = C (implication)
(A B) = C (negation)
1.30 Inference
Often one or more statements will enable us, using the rules of logic, to deduce
or infer another statement. This process of logical deduction will be called
inference. Suppose, for example, that I am sitting in a room with my friend
George, who has a degree in Meteorology. With authority he condently asserts:
(a) If it is raining and the sun is shining, then there is a rainbow in the sky.
At this precise moment, Joe enters the door, dripping wet, and says:
(b) It is raining.
At exactly the same moment, Charlie, who has been looking out of a window,
enters the room and says:
(c) The sun is shining.
From these three statements, I can condently deduce the statement:
(d) There is a rainbow in the sky.
In other words, if the propositions (a), (b) and (c) are all true, then the propo-
sition (d) must be true.
Of course, this does not mean that the propositions (a), (b) and (c) are
necessarily true. Georges meteorology may really be quite weak, and he may
have overlooked circumstances in which the sun and rain combined could fail
to produce a rainbow. Perhaps Joe and/or Charlie is lying or mistaken. But,
18
if George, Joe and Charlie are telling the truth, then it may be deduced that
the proposition (d) is true. In other words, if we assume the propositions (a),
(b) and (c), then proposition (d) follows logically from them. We say that the
proposition (d) can be inferred from the propositions (a),(b) and (c). We call
the propositions (a), (b) and (c) the premises and (d) the conclusion of the
argument.
Suppose that R denotes the proposition It is raining, S denotes The sun
is shining and Q denotes There is a rainbow in the sky. Then the proposition
(a) may be represented by RS = Q, (b) by R, (c) by S and (d) by Q. So the
argument may be expressed in the form: Q can be inferred from R S = Q,
R and S. Symbolically we express this as follows:
R S = Q
R
S
Q
We shall say that this is a valid argument. If the conclusion cannot be inferred
from the premises, then the argument is invalid. For example the following
argument is invalid:
If Jane oversleeps, she will miss the lecture. If Jane misses the
lecture, she will fail the examination. Therefore Jane will fail the
examination.
A little thought should convince you that this is not a valid argument. Symbol-
ically it may be represented by:
O = M
M = E
E
where O stands for Jane oversleeps, M stands for Jane misses the lecture
and E stands for Jane fails the examination. We can demonstrate that this
argument is invalid from the truth table:
O M E O = M M = E
T T T T T
T T F T F
T F T F T
T F F F T
F T T T T
F T F T F
F F T T T
F F F T T
Rows 1, 5, 7, 8 cover all possible cases for the truth values of O, M and E in
which the premises O = M and M = E are true. However the last row in
the table shows that the premises can both be true when the conclusion E is
false. That is the premises are true when Jane does not oversleep, attends the
lecture and passes the examination. This is clearly evident in this example by a
simple and direct observation of the given propositions, but in general the use
of a truth table is a good method to fully analyse an argument.
19
Let us use the method to test the argument:
A B
A = C
C = A
(B C) A
In this example it is not easy by just looking at the statements to decide whether
the argument is valid. The use of a truth table will make the problem much
simpler:
A B C A B A = C A C = A B C (B C) A
T T T T T F F
T T F T F F T
T F T T T F F
T F F T F F T
F T T T T T T T T
F T F T T T T T T
F F T F T T T
F F F F T T T
Note that we rst work out the truth values of the premises. Only for those
cases in which these truth values are T do we determine the truth value of the
conclusion. As the boxed entries indicate these cases only occur in the rows 5
and 6. For these cases the truth value of the conclusion is seen to be T. It
follows that the conclusion is always true when the premises are true. This
means that the argument is valid. Thus (B C) A can be inferred from the
propositions A B, A = C and C = A.
Now consider the argument:
A B
A C
B C
A = B C
The validity of the argument can be decided from the truth table:
A B C A B A C A C B B C B C A B C
T T T T F F F F F
T T F T F T T F T F F
T F T F F F F T T
T F F F F T T T T
F T T F T F T F F
F T F F T T T F T
F F T T T F T T T F T
F F F T T T T T T F T
From the table we see that the three premises are all true in the cases given
in rows 2, 7 and 8. However the conclusion of the argument is false in one of
these cases, namely that given in row 2. Hence A = B C can be false even
when A B, A C and B C are all true. Therefore the proposition
A = B C cannot be inferred from the propositions A B, A C and
B C. In other words the argument is invalid.
20
There are other ways to demonstrate that the argument is invalid. We need a
case in which the premises are true, but the conclusion is false. For A = BC
to be false, we require A to be true but B C to be false. B C is false when
at least one of B and C is false. Since A is true, A is false. Hence for AC
to be true, we require C to be true, i.e. C to be false. In this case BC is
true. Now, since A B is true and A is true, B must also be true. Thus, in
the case that A and B are true and C is false, the premises are all true, but the
conclusion is false. This case demonstrates that the argument is invalid. Note
that we could have stopped the process of constructing the truth table once row
2 had been completed, since this row by itself would have shown immediately
that the argument is invalid.
1.31 Worked Example
An economist says:
If the money supply increases, then prices will rise. Increased prices
will cause increased unemployment. On the other hand, if ination
is curbed, then unemployment will be kept in check. Therefore,
restricting the money supply will keep unemployment down.
Is this argument valid?
Solution. We must rst clarify what the argument means. The statements
that occur before the word Therefore, are the premises and the proposition
following Therefore is the conclusion. We are not asked to decide whether
the premises are true, but whether they infer the conclusion. We rst need
to express the premises symbolically. Let us denote by M the statement the
money supply rises, by P the statement prices rise and by U the statement
unemployment rises. Since ination is curbed means prices do not rise, it
is represented by P. Since unemployment is kept in check or unemployment
is kept down means unemployment does not rise, it is represented by U.
Therefore in symbols the economists argument is:
M = P
P = U
P = U
M = U
Suppose the premises are all true. Can the conclusion be false? If so, then M
must be true and U false. Thus M must be false and U true. Then M = P
and P = U are true as stated. Since P = U is true and U is false, it
follows that P cannot be true. Therefore P is false and P is true. Hence in
the case that both P and U are true and M false the premises are all true, but
the conclusion is false. Therefore the argument is invalid.
The economist may or may not understand economics, but he/she certainly
does not understand logic! As an exercise demonstrate that the argument is
invalid by constructing a truth table.
21
1.32 Worked Example
Translate the following argument into propositional logic, and determine whether
it is valid:
If the money supply increases, then prices will rise. Increased prices
will cause increased unemployment. On the other hand, if ination
is curbed, then unemployment will be kept in check. Therefore, if
unemployment is kept down, then the money supply must have been
restricted.
Solution. The premises are, of course, identical to those in the previous example.
Only the conclusion changes. Using the same notation, the conclusion may be
represented by U = M. Thus the argument maybe expressed symbolically
in the form:
M = P
P = U
P = U
U = M
To test the validity of this argument, we compile the following truth table:
M P U M P P U P U P U M U M
T T T T T F F T F T
T T F T F F T T
T F T F T T F F
T F F F T T T T
F T T T T F F T T T
F T F T F F T T
F F T T T T F F
F F F T T T T T T T
From the boxed entries, we see that rows 1, 5 and 8 represent the cases where
all the premises are true. In each of these cases, the conclusion is also true, as
seen from the last column. Therefore the argument is valid.
1.33 The Method of Formal Proof
To demonstrate that two propositions are logically equivalent we had a choice
of two methods, viz:
(i) using truth tables.
(ii) applying the logical laws to obtain a sequence of propositions starting with
one of the given propositions and ending with the other; each proposition
in the sequence being logically equivalent to the preceding proposition on
the application of a single law.
We have a similar choice of methods to show that an argument is valid. We
have already used truth tables to do this. In the next few sections we develop
a method using the logical laws and additional rules of inference, called a
formal proof.
22
1.34 Inference Rules
The following rules hold for any choice of propositions A, B and C:
(XXIV) (E or Simplication) From A B we can infer A.
(XXV) (E or Disjunctive Syllogism) From AB and A we can infer B.
(XXVI) (Modus Ponens) From A and A = B we can infer B.
(XXVII) (Modus Tollens) From A = B and B we can infer A.
(XXVIII) (E or Contradiction) From A and A we can infer B.
(XXIX) (I or Conjunction) From A and B we can infer A B.
(XXX) (I or Addition) From A we can infer A B.
(XXXI) ( I or Transitivity of Equivalence) From A B and B C
we can infer A C.
(XXXII) ( E or Law of Equivalence)
(i) From A B we can infer A = B.
(ii) From A B we can infer B = A.
(XXXIII) (The Deduction Theorem) If B can be inferred from propositions
A
1
, A
2
, . . . , A
n
and the proposition A, then A = B can be inferred
from propositions A
1
, A
2
, . . . , A
n
.
(XXXIV) (Reductio ad Absurdum) If the proposition False can be inferred
from propositions A
1
, A
2
, . . . , A
n
and the proposition B, then B can
be inferred from the propositions A
1
, A
2
, . . . , A
n
.
These rules except for the last two may be expressed by saying that certain
arguments are valid. We list these as follows:
(XXIV) A B
A
(XXV) A B
A
B
(XXVI) A
A = B
B
(XXVII) A = B
B
A
(XXVIII) A
A
B
23
(XXIX) A
B
A B
(XXX) A
A B
(XXXI) A B
B C
A C
(XXXII) (i) A B
A = B
(ii) A B
B = A
These rules may be demonstrated as usual from truth tables. The Deduction
Theorem and the rule of Reductio ad Absurdum are dierent. We use a truth
table in a dierent way. For example, the Deduction Theorem asserts that in
a truth table with atomic statements A
1
, A
2
, . . . , A
n
and A whenever the table
is constructed with truth values so that when A
1
, A
2
, . . . , A
n
and A have value
T then B has also value T then for cases when A
1
, A
2
, . . . , A
n
have value T
A = B has also value T:
A
1
A
2
. . . A
n
A B A = B
T T . . . T T T T
T T . . . T F T
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
We have listed the only two rows of importance to the theorem. Note that in
row 2 the truth value of B is not needed, since A = B is necessarily true
whenever A is false.
To explain Reductio ad Absurdum we recall that the proposition False is
always false. Therefore if the argument:
A
1
A
2
.
.
.
A
n
B
False
is valid, i.e. the conclusion has truth value T whenever the premises have value
T, it follows that the premises cannot all have value T. In particular B must be
false, i.e. B is true, whenever A
1
, A
2
, . . . , A
n
are true. Thus B can be inferred
from A
1
, A
2
, . . . , A
n
. Another way of interpreting this is say that the validity of
the above argument means that the truth of A
1
, A
2
, . . . , A
n
and B would lead
us to conclude that the proposition False is true, which is absurd. This is why
the rule is known by the (Latin) name meaning reduction to the absurd.
In the names for the rules the letter E stands for elimination and the
letter I stands for introduction. For example the rule named E involves the
elimination of and the rule named I involves introducing the connective .
24
1.35 Formal Proofs
In this section we consider the construction of a formal proof of an argument.
Suppose that we wish to prove that the following argument is valid:
A
A B = C D
C
D G
The rst few steps of the proof involves just listing the premises:
(1) A
(2) A B = C D
(3) C
From these assumptions we must deduce the conclusion that D G is true.
Because G has not been introduced in the premises, it appears that we must
obtain the truth of D and then apply I. To obtain D we could perhaps
rst deduce C D. We may work backwards in this way to nd a connection
between the conclusion and the premises. In a forward direction observe that
the proposition:
(4) A B
can be inferred from A using the inference rule I. Next, from A B and the
premise A B = C D we may deduce that:
(5) C D
is true (rule Modus Ponens). By rule E it follows that:
(6) D
is true. Then by I:
(7) D G
is true. Such a sequence of reasoning can be set down in the compact form:
(1) A
(2) A B = C D
(3) C
(4) A B
(5) C D
(6) D
(7) D G
However it may not be clear how we arrived at each step in this proof. It is
therefore useful to add the justication for each step in the proof; thus:
25
(1) A (premise)
(2) A B = C D (premise)
(3) C (premise)
(4) A B (1, I)
(5) C D (2,4, modus ponens)
(6) D (3,5, E)
(7) D G (6, I)
Within a proof we may add steps which replace a given proposition with a
logically equivalent one using one of the logical laws. Consider for example the
argument:
A = B
C = B
A C
B
The proof that the argument is valid may proceed as follows:
(1) A = B (premise)
(2) C = C (premise)
(3) A C (premise)
(4) A B (1, implication)
(5) B A (4, commutativity)
(6) C B (2, implication)
(7) B C (6, commutativity)
(8) (B A) (B C) (5,7, I)
(9) B (A C) (8, distributivity)
(10) B (A C) (9, De Morgan)
(11) (A C) B (10, commutativity)
(12) (A C) = B (11, implication)
(13) B (3,12, modus ponens)
In this proof the steps (1),(2),(3) just list the premises, steps (8) and (12) involve
rules of inference and the remaining steps apply logical laws.
1.36 Worked Example
Add the justications to the following formal proof that the argument:
A B = C
A D
C
D
is valid:
(1) A B = C
(2) A D
(3) C
(4) (A B)
26
(5) A B
(6) A
(7) D
Solution.
(1) A B = C (premise)
(2) A D (premise)
(3) C (premise)
(4) (A B) (1,3, modus tollens)
(5) A B (4, De Morgan)
(6) A (5, E)
(7) D (2,6, E)
1.37 Worked Example
Give a formal proof that the argument:
B A = C
D A
C
D
is valid.
Remark. Using a truth table is NOT a way of giving a formal proof. A formal
proof is method based only on the logical laws and the rules of inference. Note
that the solution to the previous example does not provide a solution to the
present example even if we change the order of the letters. We cannot infer A
from BA by means of E. Before we can use E we must change the order
of the letters so that we can apply E to AB to deduce A. Similarly we
must change D A to A D before applying E to obtain D. Thus we make
the following modication to the previous solution:
Solution.
(1) B A = C (premise)
(2) D A (premise)
(3) C (premise)
(4) (B A) (1,3, modus tollens)
(5) B A (4, De Morgan)
(6) A B (5, commutativity)
(7) A (6, E)
(8) A D (2, commutativity)
(9) D (7,8, E)
1.38 Worked Example
Give a formal proof that the argument:
(A = B) (C = D)
A C
B D
27
Remark. By applying E to (A = B) (C = D) and to A C we can
infer A = B and A. Hence by modus ponens we can infer B. However we
cannot use the same method directly to infer D. Again we rst have to apply
commutativity to the premises before applying this method.
Solution.
(1) (A = B) (C = D) (premise)
(2) A C (premise)
(3) A = B (1, E)
(4) A (2, E)
(5) B (3,4, modus ponens)
(6) (C = D) (A = B) (1, commutativity)
(7) C = D (6, E)
(8) C A (2, commutativity)
(9) C (8, E)
(10) D (7,9, modus ponens)
(11) B D (5,10, I)
1.39 Worked Example
Give a formal proof that the argument:
A B
B
A
Solution.
(1) A B (premise)
(2) B (premise)
(3) A = B (1, E)
(4) A (2,3, modus tollens)
Remark. To tackle this problem we obviously need a rule or law which involves
. Clearly the rule of inference E is the most appropriate here. Note
that the logical Law of Equivalence may be applied, but its usage is merely to
give a formal proof of E:
(1) A B (premise)
(2) (A = B) (B = A) (1, equivalence)
(3) A = B (2, E)
1.40 Worked Example
Give a formal proof that the argument:
P = Q
Q = R
R = S
P = S
is valid.
28
Remark. This is an example in which we make use of the Deduction Theorem.
To deduce P = Q we must show that the given premises together with the
premise P infer the proposition S. Then by the Deduction Theorem it follows
that the given premises infer P = S as required. In other words, if the
argument:
P = Q
Q = R
R = S
P
S
is valid, then the given argument is valid.
Solution.
(1) P = Q (premise)
(2) Q = R (premise)
(3) R = S (premise)
(4) P (premise)
(5) Q (1,4, modus ponens)
(6) R (2,5, modus ponens)
(7) S (3,6, modus ponens)
(8) P = S (Deduction Theorem)
The Deduction Theorem need not be applied at the end of an argument. Any
continuing argument CANNOT use any of the intermediate propositions used in
the application of the Deduction Theorem. For instance, if the above argument
were to continue after line (8), we can no longer use any of the propositions
in lines (4)-(7), since these were used only in the application of the Deduction
Theorem. We indicate that these lines form a separate transient argument by
putting them between horizontal lines. We must emphasize that no part of
this argument may be used in the main argument. Note that any such transient
argument may use any proposition or premise that occurs before that argument.
1.41 Worked Example
Give a formal proof that the argument:
P = R
Q = R
P Q
Remark. This is an example which uses Reductio ad Absurdum. To show that
the given premises infer P Q, we may show that the premise together with
the proposition (P Q) infer the proposition False and then apply Reductio
ad Absurdum. In other words if the argument:
P = R
Q = R
(P Q)
False
29
is valid then the given argument is also valid. The format is as in the previous
example; we use a transient argument to apply Reductio ad Absurdum.
Solution.
(1) P = R (premise)
(2) Q = R (premise)
(3) (P Q) (premise)
(4) P Q (3, De Morgan)
(5) P (4, E)
(6) R (1,5, modus ponens)
(7) Q P (4, commutativity)
(8) Q (7, E)
(9) R (2,8, modus ponens)
(10) False (6,9, E)
(11) P Q (Reductio ad Absurdum)
Note that in line (10) the proposition False is inferred from propositions R and
R by rule E. Indeed by this rule any proposition whatever may be inferred
from R and R. To apply Reductio ad Absurdum we need to introduce False
into the argument. There are but a few ways to do this. One way is to use the
rule E as in the above argument. Using this rule we must infer a statement
and its negation (for instance in the above argument R and R). Another way
is to use the Law of Contradiction. To use this law we need a proposition of the
form AA. For instance in the above argument lines (6) and (9) infer RR
using I. However this makes the proof a little longer. This approach would
be more appropriate if it were simpler to infer R R directly rather than to
infer R and R separately.
30
Chapter 2
PREDICATE LOGIC
2.1 Introduction
In Propositional Logic we translate English sentences into symbolic propositions
like A B = C, written in a precise mathematical language which avoids
the ambiguities of ordinary English. In Predicate Logic we carry the pro-
cess further. We attempt to extend the mathematical language so that much
more of the structure of English sentences may be considered. For example in
Propositional Logic the sentence:
If all dogs are mammals and Rover is a dog, then Rover is a mam-
mal.
may be translated into the symbolic form AB = C, where A stands for all
dogs are mammals, B stands for Rover is a dog and C stands for Rover is
a mammal. This proposition does not appear self evidently true, although the
original English sentence does appear to have this feature. The problem lies in
the translation. Some of the logical essence of the sentence has been lost in the
translation. We will now look at ways to solve this problem.
2.2 Predicates
Many English sentences state facts about some object, animate or inanimate. For
example the sentence Rover is a dog states a fact about the object Rover.
The name Rover is used here for a particular (unique) dog. Most other dogs
also have names such as Pluto or Fido. There is a common feature to the
sentences Rover is a dog, Pluto is a dog and Fido is a dog. The property
of being a dog is common to a very large class of objects. We may express these
ideas symbolically. Thus, if r stands for Rover, p for Pluto and f for Fido we
may write D(r), D(p) and D(f) for the sentences Rover is a dog, Pluto is
dog and Fido is a dog. D stands for the property of being a dog; i.e. is the
translation for is a dog. More generally, if P stands for some property, then
P(x) represents the assertion the object x has the property P. Obviously such
an assertion may be expressed in a more natural way in English. For example
the English for D(r) is better expressed as Rover is a dog than as Rover has
the property of being a dog. However the meaning is the same.
31
A unary predicate is a symbol or expression which represents a fact about
or property of some unspecied object. We apply a unary predicate to an
object to obtain a statement. Thus applying the predicate D to the object r we
obtain the statement Rover is a dog. Similarly, if M denotes the predicate
is a mammal, then M(r) is the statement Rover is a mammal. When a
predicate is applied to an object we say the it governs that object. Thus in
the proposition M(p) the predicate M governs the object p. We may apply all
the methods of Propositional Logic to propositions obtained in this way. For
example:
D(r) means Rover is not a dog.
D(r) = M(r) means if Rover is a dog, then Rover is a mammal.
M(r) = D(r) means if Rover is not a mammal, then Rover is
not a dog.
D(r) D(p) means Rover and Pluto are dogs.
Sometimes an English sentence may state a fact about two objects. For
example, John likes Mary states a fact about two (unique ) objects John
and Mary. Suppose that j represents John and m represents Mary. Let L
represent the fact that one person likes another. Thus we write L(j, m) to stand
for John likes Mary. We call L a binary predicate. A binary predicate is a
property of two unspecied objects. The property may or may not depend on
the order of objects. L(j, m) is dierent from L(m, j). However when we say
John and George are brothers, the order of John and George is irrelevant. If
B represent is the brother of and g represent George, then B(j, g) stands for
John is the brother of George. Although B(g, j) represents George is the
brother of John, it means the same thing as B(j, g). If P is a binary predicate
and x and y are objects, then we say that P governs x, y in the expression
P(x, y).
Similarly a ternary predicate is a symbol or expression which governs three
unspecied objects. For example, suppose that G represents the fact that a
person giving an object to another person. If j stands for John, b stands
for a particular book, the book, and m stands for Mary, then G(j, b, m)
represents the statement John gives the book to Mary. In this proposition the
predicate G governs the objects j, b and m. Again it is obvious that the order of
the objects governed by this predicate is important. If the order changes then so
does the statement. Although G(b, j, m) appears to be a reasonable statement
in Predicate Logic, it does not make sense in English. We will deal with this
diculty later when we introduce the notion of types.
If L, G, j, b ,mhave the above meanings, then L(j, m), L(m, j) and G(j, b, m)
etc. are propositions of Predicate Logic to which we may apply the methods of
Propositional Logic. For example:
L(j, m)G(j, b, m) means John likes Mary and gives her the book.
[This sentence is perhaps more natural than John likes Mary and
John gives the book to Mary.]
L(j, m) L(m, j) means John likes Mary, but Mary does not like
John. [Recall that but in logical terms really means and; it
merely draws attention to the contrast between the two statements.]
Note that a predicate can govern more than three objects. In general we call
32
a predicate which governs n objects an n-ary predicate. Such predicates are not
very common.
2.3 Inx Notation for Binary Predicates
Let P be a binary predicate and let x and y denote particular objects. If
P governs x and y in a particular proposition we often write xPy instead of
P(x, y). This notation follows the more natural orderings of English. Thus
with the notation j, m, L introduced earlier jLm stands for John likes Mary.
2.4 The Binary Predicates <, , >, and =
Each of these ve symbols represent a binary predicate which govern two num-
bers. To be exact, if x and y are two numbers, then:
< (x, y) means x is less than y.
(x, y) means x is less than or equal to y.
> (x, y) means x is greater than y.
(x, y) means x is greater than or equal to y
= (x, y) means x is equal to y.
It is usual, however, in mathematics to use the inx notation:
x < y means x is less than y.
x y means x is less than or equal to y.
x > y means x is greater than y.
x y means x is greater than or equal to y
x = y means x is equal to y.
2.5 Worked Example
Suppose that S is a unary predicate expressing the fact of having a railway
station, i.e. S(y) means that the town y has a railway station. Suppose that V
is a binary predicate indicating that a particular person has visited a particular
town, i.e. V (x, y) or xV y means that the person x has visited the town y.
Suppose that the following letters denote specied people and towns:
g denotes George l denotes London
j denotes John r denotes Reading
m denotes Mary w denotes Windsor
Translate the following English sentences into predicate logic:
[1] John has not visited Reading.
[2] George has visited Reading and London.
[3] George has visited Reading but not London.
[4] Mary has visited Reading or London or both.
[5] John must have visited Reading if it has a railway station.
33
[6] Although both Reading and Windsor have railway stations, John has vis-
ited neither of these towns.
Also translate the following propositions of predicate logic into English sen-
tences:
[7] jV w mV w.
[8] S(r) S(w).
Solution. [1] If we use inx notation, the proposition John has visited Read-
ing translates into jV r, and consequently John has not visited Reading
translates into jV r.
[2] George has visited Reading and London means the same thing as George
has visited Reading and George has visited London. Therefore the re-
quired translation into predicate logic is gV r gV l.
The answer is NOT gV (rl). r and l are not statements and hence cannot
be connected with . r l has no meaning in Predicate Logic. This is
true of all connectives not just . We CANNOT connect two objects with
logical connectives, since they only apply to (well-formed) propositions.
[3] George has visited Reading but not London means the same as George
has visited Reading and George has not visited London. Therefore the
proposition translates into gV r gV l.
[4] This proposition means the same as Mary has visited Reading and/or
Mary has visited London. Therefore it translates into mV r mV l.
[5] This proposition amounts to saying If Reading has a railway station, then
John has visited Reading. Hence it translates into S(r) = jV r.
[6] This statement actually means in logical terms that Reading and Windsor
have railway stations and John has not visited either Reading or Windsor.
The use of the word although merely acts to engender surprise at the
fact that John has not visited Reading nor Windsor. Thus the proposition
translates into S(r) S(w) jV r jV w. Note that we do not need to
use brackets in this statement.
[7] jV wmV w means John has visited Windsor and Mary has visited Wind-
sor. This may be written more simply as John and Mary have visited
Windsor. Note that we CANNOT express this proposition symbolically
as (j m)V w, since the connective cannot be applied to objects.
[8] S(r) S(w) means Reading has no railway station and Windsor has
no railway station. Again this may be simplied to Neither Reading nor
Windsor has a railway station. We may also express this proposition as
(S(r) S(w)), but NOT as S(r w) [r w is not allowed in Predicate
Logic. The connective can only be applied to propositions.]
34
2.6 Notation
Predicates will frequently be denoted by italicized words or combinations of
words. Although this notation lengthens the expressions used in predicate logic,
it is perhaps more informative. Thus in place of the predicate D say, which
stands for is a dog, we may write dog or perhaps is-a-dog. Similarly, we may
use words or combinations of words to denote objects. In this case we will use
a sans-serif font type. Thus for example Rover may be used to denote Rover.
For example we may write is-a-dog (Rover) to mean Rover is a dog. Similarly
we may write John likes Mary to mean John likes Mary. In some cases, like
this example, the symbolic form is exactly the same as the English form apart
from the dierent font types used.
2.7 Types
Suppose, for example, that H is a unary predicate expressing the fact of being
happy. Suppose that j stands for John and m stands for Mary. Then H(j)
means John is happy and H(m) means Mary is happy. In general H(x)
means x is happy, where x is the name of any person. However, if x denotes a
particular chair, then H(x) would not make sense. Therefore when we consider
a unary predicate, we usually have in mind some type of object which it is
allowed to govern. For instance if P is the set of all people, we might agree that
the predicate H is only allowed to govern those objects belonging to P. Then
H(x) is only a proposition, i.e. is true or false, when x stands for an object in
P. We say that P is the domain or the domain of denition of H. An object of
P is called an object of type P. Thus a type is just a collection of objects.
If x is an object of type P, we write, in symbols, x : P. This is an abbreviation
for x is of type P, or, in this particular case, x is a person.
A binary predicate governs two objects. In this case, the rst object must
be of a specic type and the second object must be of some, perhaps dierent,
specic type. For example, consider the binary predicate, V , which expresses
the fact that a person has visited a town, so that V (x, y) or xV y means that
the person x has visited the town y. Thus V (x, y) or xV y only makes sense if
x is the name of a person and y is the name of a town. In other words, if P
denotes the set of all people and T denotes the set of all towns, we require x to
be of type P and y to be of type T. The expression V (x, y) or xV y only makes
sense if x : P and y : T. On the other hand, the predicate, L, which expresses
the liking of one person for another, governs two objects of same type P. Thus
L(x, y) or xLy only makes sense if x : P and y : P.
In Mathematics, there are particularly important types of objects for which
we give a standard xed notation. These are the following special number types:
Z denotes the set of integers (i.e. whole numbers). Thus Z consists of the
numbers:
. . . , 3, 2, 1, 0, 1, 2, 3, . . .
N denotes the set of natural numbers, i.e. the non-negative integers. Thus
N consists of the numbers:
0, 1, 2, 3, . . .
35
N
1
denotes the set of all positive integers. Thus N
1
consists of the numbers:
1, 2, 3, 4, 5, . . .
Q denotes the set of all rational numbers, i.e. numbers of the form
p
q
, where
p, q are integers with q ,= 0. Thus Q consists of fractions such as
1
2
,
3
4
and
2
7
.
R denotes the set of all real numbers, i.e. numbers which have a, possi-
bly innite, decimal representation. Real numbers include both rational
numbers and irrational numbers such as ,

2 and e.
Remark. In some textbooks and courses N is dened to be the set of all positive
integers, i.e. the set N
1
.
2.8 Quantiers
In Mathematics, we often make statements involving the words for all and
there exists or words to the same eect. For example we might write:
for all real numbers x, x < x + 1,
which means that for every real number x, whatever its value, x is less than
x + 1. Similarly the assertion:
for all persons x, x likes chocolate
means that everyone likes chocolate. We use the symbol to represent the
words for all. Similarly we use the symbol to represent the words there
exists. The statement:
for all persons x, x likes chocolate
may be represented in Predicate Logic in the symbolic form:
x : P xLc,
where P denotes the set of all people, L denotes the predicate likes and c
denotes chocolate. The expression x : P is called a quantier, more precisely
a universal quantier. We use the symbol to separate the quantier from the
predicated statement xLc. In the same way we express the statement for all
real numbers x, x is less than x + 1 in the symbolic form:
x : R x < x + 1.
Suppose that S expresses the fact that a town has a railway station, and
that V represents the fact that a person has visited a town. Let P denote the
set of people and T denote the set of towns. Then the statement there exists
a town with a railway station may be translated to:
x : T S(x).
Note that in this case the symbol represents the words such that and also
separates the quantier x : T from the predicated statement S(x). The quan-
tier here is called an existential quantier. Note also that there are many other
ways to express this statement in English, for example:
36
At least one town has a railway station;
or, Some town has a railway station.
Similarly the statement there is at least one town without a railway station
may be translated into:
x : T S(x).
Note that this statement may also be expressed in English in the form:
Not all towns have a railway station.
This version translates into:
x : T S(x).
If j denotes John, then the statement John has visited at least one town
translates into:
y : T jV y.
[In loose English there exists an object y of type town such that John has
visited y.]
Suppose that we wish to translate the statement there is a unique town
that has a railway station Here the word unique has the same meaning as
the words one and only one. In this case we use the symbol
1
. Thus the
statement translates into:

1
x : T S(x).
Similarly the proposition John has visited one and only one town becomes:

1
y : T jV y.
A quantier involving
1
is called a unique quantier.
2.9 Restricted Quantiers
Quantiers such as x : P, y : T and
1
y : T are known as unrestricted quan-
tiers. Sometimes we wish to restrict the range of possibilities for a quantied
variable. Such modied quantiers are called restricted quantiers. For exam-
ple, suppose that in the quantier x : N we wish to restrict the possibilities
of x to those natural numbers less than 12. The modied quantier is denoted
by x : N[x < 12. This quantier literally means for all x of type N such that
x < 12 or, in better English, for all natural numbers x for which x < 12.
The symbol [ is short hand for for which. The proposition:
x : N[x < 12 x < 20
therefore means for every natural number x less than 12, x is less than 20, or
every natural number less than 12 is less than 20. Similarly the proposition:
y : T[jV y S(y)
means for every town y which John has visited, y has a railway station, or
every town which John has visited has a railway station.
37
Expressions such as x : N[x < 12 and y : T[jV y are called restricted
universal quantiers. In general such quantiers have the form x : X[Q, where
X denotes a type and Q is a statement about any object x of type X. Indeed
Q is a predicated statement involving a predicate which at least governs objects
of type X.
We can avoid using a restricted quantier by using the connective = in-
stead. A proposition of the general form:
x : X[Q P,
where P is a predicated statement with a predicate which governs at least objects
of type X, is equivalent to the proposition:
x : X Q = P.
In other words, a proposition of the form for all x of type X such that Q is
true, P is true can be replaced by the proposition for all x of type X, if Q,
then P. Thus, for example:
x : N[x < 12 x < 20
(i.e. every natural number less than 12 is less than 20) can be replaced by:
x : N[ x < 12 = x < 20
(i.e. for every natural number x, if x < 12, then x < 20) and:
y : T[jV y S(y)
(i.e. every town which John has visited has a railway station) can be replaced
by:
x : T jV y = S(y).
(i.e. for every town y, if John has visited y, then y has a railway station)
We also sometimes use restricted existential quantiers. For example:
x : N[x < 12,
which means for some object x of type N such that x < 12 or for some
natural number x less than 12 or there exists a natural number x less than
12 such that . . .. In particular:
x : N[x < 12 x > 10
means there exists a natural number x less than 12 such that x < 10 or there
exists a natural number less than 12 which is greater than 10. If we use the
symbols, such as T, V j etc., dened previously, then:
y : T[jV y
would mean for some town y which John has visited and hence:
y : T[jV y S(y)
38
would mean there exists a town which John has visited that has a railway
station. In general a restricted existential quantier has the form x : X[Q,
where Q is an assertion about x.
We can avoid using a restricted existential quantier by using the connective
instead. For example the statement that there exists a natural number less
than 12 which is greater than 10 may be expressed in the form: there exists a
natural number which is less than 12 and greater then 10; i.e.:
x : N x < 12 x > 10.
Similarly the proposition:
y : T[jV y S(y)
may be replaced by:
y : T jV y S(y).
Thus restricted quantiers may avoided, but often their use may be more con-
venient and easier to interpret.
39
2.10 The Scope of a Quantier
To illustrate the ideas contained in this section we will use the previous notations
such as T, V and j. In the proposition x : T S(x), we say that the scope
of the quantier x : T is S(x). Similarly the scope of the quantier x :
T in the proposition x : T S(x) is the assertion S(x). Note that the
scope of a quantier is always an expression concerning the variable declared in
the quantier. Thus the scopes of the quantiers in the above statements are
assertions about the variable x, which was declared within the quantier.
There are situations in which the scope of the quantier is somewhat am-
biguous. Thus, for example, how should we interpret the proposition x : T
S(x) = jV r? It is not clear whether this proposition means x : T (S(x) =
jV r) or (x : T S(x)) = jV r. In predicate logic, we use the convention
that the scope of the quantier consists of everything which comes after the
which immediately follows the quantier, unless brackets are used to indicate
otherwise. A quantier with its scope forms a complete sentence or assertion,
which may be delimited by brackets when part of a compound proposition.
Therefore in the statement x : T S(x) = jV r, the scope of the quantier is
S(x) = jV r. If the scope of the quantier is meant to be just S(x), then we
MUST use brackets:
(x : T S(x)) = jV r.
The brackets are used here to delimit the statement x : T S(x) which is
connected to the statement jV r with the connective = to form the whole
compound proposition.
If a quantier appears between brackets, then its scope is everything which
occurs after the which immediately follows the quantier but is between the
nearest pair of brackets which enclose the quantier. Consider, for example, the
proposition:
jV l (mV r (gV w x : T S(x) (jV x jV r)) mV l).
In this proposition the pair of brackets nearest to the quantier delimit the
statement:
gWr = x : T S(x) (jV x jV r).
Hence the scope of the quantier is:
S(x) (jV x jV r).
Note that the quantier with its scope forms the statement:
x : T S(x) (jV x jV r)
and that it is unnecessary to delimit this statement in the whole proposition
with a pair of brackets, since this omission does not produce an ambiguity. The
same rules apply to restricted quantiers. A proposition may contain many
quantiers, being built up using lots of atomic statements combined with con-
nectives and quantiers. The above rules allow us to determine the scope of
each quantier, so that 7by parsing the proposition we may obtain its correct
interpretation.
40
2.11 Worked Example
Let P be the set of all people. Suppose that sensible, stupid, architect,
fishmonger, thief are unary predicates indicating being sensible, being stupid,
being an architect, being a shmonger and being a thief respectively. Thus, for
example, sensible(x) means that the person x is sensible. Suppose that admires
is a binary predicate indicating that one person admires another and suppose
that taller-than is a binary predicate indicating that one person is taller than
another. Using John and Sue as symbols for particular people, translate the
following English sentences into predicate logic:
(a) Everybody admires John.
(b) Sue admires somebody.
(c) Everyone who admires Sue is stupid.
(d) John admires at least one person who is taller than Sue.
(e) All sensible people admire John.
(f) Every architect is taller than John.
(g) Some shmonger is shorter than John.
(h) Every shmonger is a thief.
(i) No architect is a thief.
(j) If all shmongers are thieves and John is a shmonger, then John is a thief.
(k) If you are taller than John, then you must be taller than Sue.
(l) John admires everybody and is taller than Sue.
Solution. (a) This proposition may be expressed in the form: For every person
x, x admires John. Hence its translation into predicate logic is:
x : P x admires John.
(b) In this case the proposition may be expressed in the form: There exists a
person x such that Sue admires x. Hence the translation is:
x : P Sue admires x.
(c) There are at least two ways of translating this sentence into predicate logic;
either using a restricted quantier:
x : P [ x admires Sue stupid(x);
or instead using an unrestricted quantier:
x : P x admires Sue = stupid(x).
41
(d) In this case we may use a restricted or unrestricted existential quantier:
x : P [ x taller-than Sue John admires x.
or:
x : P x taller-than Sue John admires x.
(e) This sentence may be written: For every person x such that x is sensible,
x admires John. Possible translations include:
x : P [ sensible(x) x admires John;
and:
x : P sensible(x) = x admires John.
(f) We may express this sentence as For every person x such that x is an
architect, x is taller than John. Thus possible translations are:
x : P [ architect(x) x taller-than John;
and:
x : P architect(x) = x taller-than John.
(g) This sentence may be expressed as For some person x such that x is a
shmonger, John is taller than x. Hence possible translations are:
x : P [ fishmonger(x) John taller-than x;
and:
x : P fishmonger(x) John taller-than x.
(h) Possible translations are:
x : P [ fishmonger(x) thief(x);
and:
x : P fishmonger(x) = thief(x).
(i) Possible answers are:
x : P [ architect(x) thief(x);
and:
x : P architect(x) = thief(x).
(j) Because we should now be familiar with the use of both restricted and
unrestricted quantiers, in future we will only write down one of the two
possible cases. A solution in this example is:
(x : P [ fishmonger(x) thief(x)) fishmonger(John) = thief(John).
(k) A solution is:
x : P [ x taller-than John x taller-than Sue.
(l) A solution is:
(x : P John admires x) John taller-than Sue.
Note that if we interchange the constituent statements in this proposition
we may remove the brackets. Thus an alternative solution with no brackets
is:
John taller-than Sue x : P John admires x.
42
2.12 Multiple Quantiers
The scope of a quantier may also involve one or more quantiers. For example
the proposition:
x : N y : N x < y.
The scope of the quantier x : N is the assertion:
y : N x < y,
which involves the quantier y : N. Note that the whole proposition is true,
since given any natural number x there always exists a natural number y such
that x < y. However, if we interchange the quantiers, we obtain the proposi-
tion:
y : N x : N x < y,
which is clearly false; no natural number can be greater than every natural num-
ber. It follows that the order of the quantiers in such propositions are crucial
to the meaning of the proposition. However the order does not matter when
we combine two universal quantiers or combine two existential quantiers. For
instance the two propositions:
x : N y : N x y x > y
and:
y : N x : N x y x > y
mean the same thing as do the two propositions:
x : N y : N x < y y < 2
and:
y : N x : N x < y y < 2.
A general proposition of the form:
x
1
: X x
2
: X . . . x
n
: X Q(x
1
, x
2
, . . . , x
n
),
where Q(x
1
, x
2
, . . . , x
n
) is an assertion about the variables x
1
, x
2
, . . . , x
n
, may
be translated into English in the simplied form: For all objects x
1
, x
2
, . . . , x
n
of type X the assertion Q(x
1
, x
2
, . . . , x
n
) is true. We may therefore use a
simplied notation in predicate logic:
x
1
, x
2
, . . . , x
n
: X Q(x
1
, x
2
, . . . , x
n
).
We may use a similar simplied notation for existential quantiers:
x
1
, x
2
, . . . , x
n
: X Q(x
1
, x
2
, . . . , x
n
)
instead of the expanded form:
x
1
: X x
2
: X . . . x
n
: X Q(x
1
, x
2
, . . . , x
n
).
There are similar abbreviations for mixed types:
x
1
: X
1
; x
2
: X
2
; . . . ; x
n
: X
n
Q(x
1
, x
2
, . . . , x
n
).
43
and:
x
1
: X
1
; x
2
: X
2
; . . . ; x
n
: X
n
Q(x
1
, x
2
, . . . , x
n
).
For example, if P, T, V have the meanings given in previous sections, the propo-
sition:
x : P y : T xV y,
meaning that every person has visited every town, may be abbreviated to:
x : P; y : T xV y.
Similarly the proposition:
x : N y : N z : N x < y y < z
may be abbreviated to:
x, y, z : N x < y y < z.
If W is a ternary predicate and W(x, y, n) means that a person x has visited a
town y at least n times, then the proposition:
x : P y : T n : N W(x, y, n)
can be shortened to:
x : P; y : T; n : N W(x, y, n).
If we wish to write down the scope of a quantier that occurs within a
multiple quantier in a proposition, we need to replace all omitted quantiers
necessary to achieve this. For example the proposition:
x, y : N x y x > y.
combines the quantiers x : N and y : N. To determine the scope of the
quantier x : N we need to replace both the omitted quantiers; thus:
x : N y : N x y x > y.
Then the scope of the quantier x : N is:
y : N x y x > y.
The scope of the quantier y : N is x y x > y.
If you were asked to replace the omitted quantiers in the proposition:
((x : P; y : T S(y) xV y) (x, y : R x < y y < 1)) jV r
the answer would be:
((x : P y : T S(y) = xV y)
= (x : R y : R x < y y < 1)) jV r.
From this we can see that:
44
(i) the scope of x : P is:
y : T S(y) = xV y;
(ii) the scope of y : T is: S(y) = xV y;
(iii) the scope of x : R is:
y : R x < y y < 1;
(iv) the scope of y : R is: x < y y < 1.
2.13 Worked Example
Let T be the set of all towns. Let V be a binary predicate indicating that
a particular person has visited a particular town, i.e. V (x, y) or xV y means
that person x has visited town y. Using this notation and the notation in
Example 2.11, translate the following English sentences into predicate logic:
(a) There is a person who has visited every town.
(b) Every town has had at least one visitor.
(c) Everybody admires somebody who is taller than Sue.
(d) Somebody who is shorter than Sue admires everybody who is taller than
Sue.
(e) If one person is taller than another then the latter is not taller than the
former.
(f) Somebody has visited at least one town.
Solution. (a) This sentence may be expressed as follows: There exists a person
x such that x has visited every town. The sentence x has visited every
town means for every town y, x has visited y. This may be translated
into predicate logic as:
y : T xV y.
Hence the full sentence translates into:
x : P y : T xV y.
(b) This sentence may be expressed in the form: For every town y, y has had
at least one visitor. The sentence y has had at least one visitor means
there exists a person x such that x has visited y. This translates into
predicate logic as:
x : P xV y.
Thus the full translation is:
y : T x : P xV y.
(c) In this case the sentence means:
45
For every person x, x admires somebody who is taller than Sue.
The sentence x admires somebody who is taller than Sue may be expressed
in the form: There exists a person y who is taller than Sue such that x
admires y. This translates into predicate logic as:
y : P [ y taller-than Sue x admires y.
Therefore the whole sentence translates into:
x : P y : P [ y taller-than Sue x admires y.
(d) This sentence means For some person x who is shorter than Sue, x admires
everybody who is taller than Sue, i.e. There exists a person x such that
Sue is taller than x with the property that, for every person y such that y
is taller than Sue, x admires y. This translates into:
x : P [ Sue taller-than x y : P [ y taller-than Sue x admires y.
(e) This sentence may be expressed in the form If a person x is taller than a
person y, then y is not taller than x. It does not matter which persons
x and y refer to. The sentence applies to all persons x and y. Thus the
sentence translates into predicate logic as:
x, y : P x taller-than y = y taller-than x.
Note that the word all or any of its equivalents does not actually appear
in the sentence. However it is nevertheless implied, since the sentence does
not refer to specic people. The sentence asserts the truth of the statement
x taller-than y = y taller-than x however we choose the people x and
y; i.e for all people x and y.
(f) This sentence means: There exists a person x and a town y such that x
has visited y; i.e.
x : P; y : T xV y.
Of course there are other equivalent expanded forms of this statement.
2.14 Variables and Constants
We can distinguish between symbols which represent a particular object and
symbols which represent unspecied objects. Usually unspecied objects are
those which have been declared by a quantier which just species its type and
not a particular object. The symbols which represent these unspecied objects
are called variables. A variable may be replaced by the label of a particular
object of the same type and any associated quantier removed to obtain a
proposition about the particular object. Symbols which represent particular
objects are called constants. For example, in the proposition:
x, y : N x < y y < 2
the symbols x and y are variables and the symbol 2 is a constant, since it is
the label of just one particular number. To test the truth of this proposition
46
we must replace the variables x and y by particular numbers and then test the
statement x < y y < 2 for its truth value. We must try all possible choices of
values of x and y. If for just one particular choice, the statement x < y y < 2
is true, then our proposition is true. The use of variables in predicate logic is
very similar to the use of variables in algebra. We say that a quantier is over
a variable if the quantier declares that variable. For example the quantiers
x : T, x : R,
1
x : N and x, y : N are all quantiers over x. Note that
x, y : N is also a quantier over y.
In predicate logic, an occurrence of a variable, x, in an expression is said
to be bound, if it lies within the scope of a quantier over x. Variables in an
expression which are not bound variables are said to be free variables. For
example in the expression x : P xV y the variable x is a bound variable,
since it is declared by the quantier, x : P, but the variable y is a free variable,
since it has not been declared in the expression by any quantier. We say that
x is bound by the quantier x : P. Whether a given variable is bound or not
depends on the expression in which it occurs. For example, in the expression:
y : T x : P xV y
the variable y is now a bound variable. As we have seen above, in the scope
of the quantier y : T (as an expression in its own right) y is a free variable.
Again in the expression:
x : N y : N z y y < x.
all the occurrences of the variables x and y are bound, but z is a free variable.
Now consider the proposition:
((x : P y : T S(y) = xV y)
= (x : R y : R x < y y < 1)) jV r.
All occurrences of the variables x and y are bound. However the two occurrences
of x before the connective = are bound by the quantier x : P, whilst the
other occurrences of x are bound by the quantier x : R. Similarly each
occurrence of y is bound by one of two dierent quantiers; namely y : T
and y : R. Note that there are no free variables in this proposition and that
there are two constants; namely j and r. Great care must be taken when a
symbol is used to denote two essentially dierent objects in a proposition. A
bound variable x has inuence extending only to the scope of the quantier
over x; i.e. all occurrences of x in a quantier over x and its scope are bound
by that quantier and all other occurrences of x are either free or bound by a
dierent quantier. If diculties arise over the use of a symbol in more than
one context, then use should be made of other symbols, so that each object
is represented by a symbol unique to that object. Thus the above proposition
perhaps may more clearly and unambiguously expressed in the form:
((x : P y : T S(y) = xV y)
= (u : R v : R u < v v < 1)) jV r.
We know that, in the context of this proposition, the symbols j and r are
constants, since we are given this fact in advance.
47
Recall that we considered an expression:
x : N y : N z y y < x.
This expression cannot be a proposition, since we cannot determine whether
it is true or false. The reason is that the expression contains a free variable;
namely z. On replacing z with a particular object, the expression becomes a
proposition. Certain choices make the proposition true; others make it false. It
is only when we replace the free variable z with a constant that a truth value
can be determined.
Any expression made up of symbols from the language of predicate logic is
called a formula. A formula which has a truth value whenever each free variable
is assigned a value; i.e. is replaced by a constant is said to be well formed.
We will often abbreviate the words well formed formula to w. For example
the expression x : N is a formula, which is not a proposition nor well formed.
The expression y : N x < y is a well formed formula, but not a proposition.
Finally the expression x : N y : N x < y is a proposition; indeed it is a true
proposition.
In creating a well formed formula in predicate logic, we must follow the
precise rules of syntax in the language of predicate logic. The following give
examples of errors of syntax that might occur:
(i) j : PjV y, where j stands for John. Here j is a constant and quantiers
can only declare variables. The expression x : X only makes syntactic
sense, when x is a variable and X stands for a type; i.e. a set of objects.
(ii) x : P x admires John [ x admires Sue. The symbol [ must immediately
follow the quantier that it is restricting. The scope of the quantier is
x admires John [ x admires Sue and this assertion does not make syntac-
tic sense.
(iii) x : P x admires John x admires Sue. A must immediately follow a
quantier, but the second does not. The scope of the quantier x : P is
the expression x admires Johnx admires Sue, which does not make sense,
since the in this expression does not immediately follow a quantier.
(iv) The expression x : P [ xV y does not mean the same as x : P xV y.
Indeed it cannot be a well formed formula, since it only denotes a restricted
quantier without a scope.
The expression x : P xV y is a w. The variable y in this formula is a free
variable. We may replace y by l, say, where l stands for London. Then the
formula becomes the proposition x : P xV l. This process is called assigning
the value l to y.
The formula y : N x < y y < z contains two free variables, x and z. We
claim that this formula is well formed. If we assign the value 3 to x and the
value 5 to z, then the resulting formula is a true proposition. On the other hand
the assignment of 5 to x and 3 to z yields a false statement. Of course there
is no explicit reason why we should restrict the assignment of values to x and
y from within the set N. However there is a problem here concerning whether
the expression x < y is a w. This is not strictly a problem within predicate
logic itself, but more one concerning the particular application of predicate
48
logic to mathematics. We apply the predicate logic to many deductive sciences
including mathematics and computer science. In these applications we use the
logic to deduce propositions and formulae about the subject from other known
propositions and formulae on the subject. Hence, when deciding whether a
formula is well formed, in addition to the formal structures of predicate logic we
have also to consider the formal structures of the given science. This means that
free variables may not be completely free in the sense that we may assign any
value whatever to them, but that they may be freely chosen from a particular
set; i.e. the type of the variable. Thus in the above formula, the types of x and
z may be implicitly regarded as the set N. In this case it is absolutely clear that
the formula, y : Nx < yy < z, is well formed. In most applications the type
of a free variable is usually declared before the variable is used in a formula.
2.15 Worked Example
In the six well formed formulae (i)-(vi) of predicate logic listed below, all vari-
ables represent objects belonging to Z (i.e. integers).
(a) For each of the formulae which contains no free variables, state whether it
is true or false.
(b) For each of the formulae which contains one or more free variables, give an
example of an assignment of value(s) to the free variable(s) which make the
formula true.
(c) For each of the formulae which contains one or more free variables, give an
example of an assignment of value(s) to the free variable(s) which make the
formula false.
(i) x : Z x 0.
(ii) x : Z x < y x > 2.
(iii) x : Z y : Z y < x.
(iv) x : Z (x = y y = z).
(v) x, y : Z t < x x < y y < z.
(vi) x, y : Z x > y.
Solution. (i) In this formula there is only one variable; namely x. There are
two occurrences, both bound by the quantier x : Z. Hence there are
no free variables. The formula is therefore a proposition. Since there
obviously exists at least one number which is less than or equal to 0, the
proposition is true.
(ii) In this formula there are two dierent variables; namely x and y. There
are three occurrences of x, all bound by the quantier x : Z. However
y is not bound by a quantier and hence is a free variable. The formula
is not a proposition and so cannot be assigned a truth value. To assign
a value to y to make the formula a true proposition, we need a value of
y so that there exists an integer x such that x < y and x > 2. It follows
49
that y must be chosen to be greater than or equal to 4. In particular if
we assign the value 4 to y, then the formula becomes a true proposition.
On the other hand, if we assign the value 3, say, to y, then the formula
becomes a false proposition. The full analysis of this formula is that, if y
is assigned a value greater than or equal to 4, then the formula is a true
proposition, but, if y is assigned a value less than or equal to 3, then the
formula is a false proposition.
(iii) There are two variables, x and y, in this formula. The occurrences of x
are bound by the quantier x : Z and the occurrences of y are bound by
the quantier y : Z. Hence there are no free variables. The formula is
a proposition. The proposition asserts that for any integer x there exists
an integer y such that y < x. This is obviously true; for instance we may
choose y to be x 1.
(iv) In this case there are three variables, x , y and z. Only one of them, x,
is bound by the quantier x : Z. Hence y and z are free variables. The
formula is not a proposition. The formula x = y x = z asserts that x
is both equal to y and z. This can only be true when x = y = z. Thus
(x = y x = z) can only be false when x = y = z. Hence, if y ,= z, the
formula (x = y x = z) is always true whatever the value of x. Thus,
for example, if we assign the values 0 to y and 1 to z, then the formula
becomes a true proposition. If we assign the same value to both y and z,
say the value 0, then x = y x = z is true when x = 0 and false otherwise.
Hence (x = y x = z) is false when x = 0 and true otherwise. Therefore
the proposition x : Z (x = y x = z) is false. [Note that a proposition
involving a universal quantier x : X is false whenever its scope is false
for just one value of x.]
(v) In this example there are four variables, t, x, y and z. The variables x
and y are bound by the multiple quantier x, y : Z, since this quantier
expands to the two quantiers x : Z and y : Z. Hence there are two
free variables, t and z. The formula is not a proposition and hence cannot
be assigned a truth value. The formula asserts that there exist integers
x and y such that t < x, x < y and y < z. This is true if z t > 2,
but false otherwise. For example, if t = 0 and z = 3, then the assertion
t < x, x < y and y < z is true when x = 1 and y = 2. Thus the formula
becomes a true proposition when t is assigned the value 0 and z is assigned
the value 3. On the other hand if, say, t = 0 and z = 2, then the formula
becomes a false proposition. In this case we cannot assign values to x and
y so that the assertion t < x, x < y and y < z is true.
(vi) In this example there are no free variables. The only variables are x and
y and these are bound by the quantier x, y : Z. The formula is a
proposition which asserts that, for all integers x and y, x is greater than
y. This is obviously false.
To recap we have the following answers:
(a) (i) and (iii) contain no free variables and are true.
(vi) contains no free variables and is false.
(b) (ii) is true when y = 4.
50
(iv) is true when y = 0 and z = 1.
(v) is true when t = 0 and z = 3.
(c) (ii) is false when y = 3.
(iv) is false when y = 0 and z = 0.
(v) is false when t = 0 and z = 2.
When asked a question of this sort you need not give full explanations as
in this worked example, but just the nal answers as in the recap above. The
preliminary explanations were added here to help you see how the nal answers
might be thought out. You must however give actual assignments to the free
variables and not a full analysis such as (iv) is true when y ,= z and false when
y = z. The question asks only for examples of an assignment of values to the
free variables.
51
Chapter 3
PROOF BY INDUCTION
3.1 Introduction
The Principle of Mathematical Induction is based on a property of the system
of natural numbers. This property, called the inductive property, states that, if
S is a set of natural numbers such that:
(i) 0 belongs to S;
(ii) Whenever n belongs to S, n + 1 belongs to S,
then S = N. This property is one of the properties which characterize the set of
natural numbers, N, and is accepted without proof. In any deductive science we
must start with some basic premises or truths, called axioms which are accepted
without proof. All other facts are then deduced from these using the rules of
logic. As we have seen all arguments in logic start with a number of premises
from which a certain conclusion is deduced. The axioms are usually properties
which seem self evident in the particular subject. Thus the above inductive
property of the natural numbers seems to be self evident. If 0 belongs to S,
then 1 = 0 + 1 must belong to S, and then 2 = 1 + 1 belongs to S and so
on. Therefore every natural number belongs to S. The problem lies with the
phrase and so on. In some sense there is an act of faith in the deduction that
every natural number belongs to S. It is this that we accept as an axiom for
the system of natural numbers. The axiom deals with the phrase and so on
by the requirement that whenever n is in S, then n + 1 is in S. This is better
expressed in logical terms as follows:
n : N n S = (n + 1) S.
Using the inx notation the symbol represents the binary predicate is a
member of. Thus n S means that n is a member of the set S. Thus the
inductive principle for the natural numbers asserts the truth of the proposition:
0 S (n : N n S = n + 1 S) = S = N.
We may apply the inductive principle to the following situation. Suppose
that for each natural number n we have a proposition, denoted by P(n). In the
language of predicate logic we may say that P is a unary predicate with domain
52
N. Thus the proposition P(n) asserts some fact about the natural number n.
Suppose that we wish to prove that P(n) is true for every natural number n.
Consider the set S of all natural numbers n for which P(n) is true. Then we wish
to show that S = N. This could be achieved by applying the inductive principle
to S. Hence we must demonstrate the truth of the following statements:
(i) 0 S;
(ii) n : N n S = n + 1 S.
The statement 0 S is equivalent to the statement P(0) is true. The state-
ment:
n : N n S = n + 1 S
is equivalent to the statement:
for all natural numbers n, if P(n) is true, then P(n + 1) is true.
Therefore to prove that P(n) is true for all natural numbers n it suces to prove
that:
[1] P(0) is true;
[2] For all natural numbers n, if P(n) is true, then P(n + 1) is true.
This method of proof is called the Principle of Mathematical Induction or simply
proof by induction. Note that proof by induction requires two steps. The rst
step is to show that P(0) is true. The second step, called the inductive step, is
to show that, for all natural numbers n, P(n) = P(n + 1).
3.2 Worked Example
Prove by induction that, for every natural number n:
n

r=0
r =
1
2
n(n + 1)
i.e.
0 + 1 + 2 + +n =
1
2
n(n + 1).
Solution. For every natural number n, let P(n) be the statement:
n

r=0
r =
1
2
n(n + 1).
First Step: P(0) asserts that:
0

r=0
r =
1
2
0(0 + 1).
There is only one term in the sum; namely when r = 0. This term has value
0. Hence the sum on the left hand side of the equation is equal to 0. Also
1
2
0(0 + 1) = 0. Hence P(0) is true.
53
Inductive Step: Let n be any natural number and assume that P(n) is true.
Then:
n

r=0
r =
1
2
n(n + 1).
Therefore:
n+1

r=0
r =
n

r=0
r + (n + 1)
=
1
2
n(n + 1) + (n + 1)
=
1
2
(n + 1)[n + 2]
=
1
2
(n + 1)[(n + 1) + 1].
i.e.
n+1

r=0
r =
1
2
(n + 1)[(n + 1) + 1].
This is exactly what the statement P(n + 1) asserts. Hence the statement
P(n + 1) is true.
It follows by induction that the statement P(n) is true for every natural
number n.
The argument in the inductive step has been the result of writing down
both propositions P(n) and P(n + 1) and then comparing them. Note that, if
a
n
denotes, for each natural number, an expression involving n, then from the
denition of the sum symbol

:
n+1

r=0
a
r
= a
0
+a
1
+a
2
+. . . +a
n
+a
n+1
= (a
0
+a
1
+a
2
+. . . +a
n
) +a
n+1
=
n

r=0
a
r
+a
n+1
.
In the inductive step we are given; i.e. may assume; the value for the sum

n
r=0
r. Using the above argument, we may express

n+1
r=0
r as the sum of

n
r=0
r and (n + 1), and then using some appropriate algebraic manipulation
determine the required value of

n+1
r=0
r.
3.3 Worked Example
Let a
0
, a
1
, a
2
, . . . be an innite sequence of numbers such that a
0
= 4 and
a
n+1
= 2a
n
+ 3 for every natural number n. Prove that a
n
= 7 2
n
3 for
every natural number n.
Solution. Let P(n) denote the statement a
n
= 7 2
n
3. We have to prove
that P(n) is true for all natural numbers n
54
First Step: The statement P(0) asserts that a
0
= 72
0
3. Now 72
0
3 =
7 3 = 4. Hence in reality P(0) asserts that a
0
= 4. But the truth of the
statement a
0
= 4 is given. Thus P(0) is true.
Inductive Step: We have to show that for every natural number n P(n) =
P(n + 1). Therefore let n be a natural number and suppose that P(n) is true.
Then a
n
= 7 2
n
3. We must show that P(n + 1) is true; i.e. that a
n+1
=
72
n+1
3. To prove P(n+1), we must nd some way to connect the statement
P(n +1) with the statement P(n). In this case the connection is clear. We are
given that a
n+1
= 2a
n
+ 3. Hence, combining this equation with the equation
a
n
= 7 2
n
3 given above and using some simple manipulations, we have:
a
n+1
= 2a
n
+ 3
= 2(7 2
n
3) + 3
= 7 2 2
n
6 + 3
= 7 2
n+1
3.
Thus we have deduce the statement P(n+1). Since the above argument is valid
for all natural numbers n, the inductive step is complete.
It follows, by the Principle of Mathematical Induction, that the proposition
P(n) is true for every natural number n. Thus a
n
= 7 2
n
3 for all natural
numbers n.
Note that explanations have been added to the inductive step to help for-
mulate a proof. In practice most of this analysis need only be done on a sheet
of rough paper. Once the essential ideas of a proof have been worked out, only
the nal version, with a direct line of argument, need be written down.
3.4 Worked Example
Let a
0
, a
1
, a
2
, . . . be an innite sequence of numbers such that a
0
= 8 and
a
n+1
= 3a
n
+ 2n
2
for every natural number n. Prove by induction that for
every natural number n:
a
n
= 3
n+2
n
2
n 1.
Solution. For each natural number n, let P(n) be the statement:
a
n
= 3
n+2
n
2
n 1.
First Step: P(0) asserts that a
0
= 3
0+2
0
2
01. But 3
0+2
0
2
01 =
3
2
1 = 8. We are given that a
0
= 8. Hence P(0) is true.
Inductive Step: Let n be a natural number and assume that the statement
P(n) is true. Then:
a
n
= 3
n+2
n
2
n 1.
55
Then:
a
n+1
= 3a
n
+ 2n
2
= 3(3
n+2
n
2
n 1) + 2n
2
= 3 3
n+2
3n
2
3n 3 + 2n
2
= 3
n+3
n
2
3n 3
= 3
n+3
(n
2
+ 2n + 1) n 2
= 3
(n+1)+2
(n + 1)
2
(n + 1) 1
Thus the statement P(n + 1) is true.
Therefore by induction the statement P(n) is true for every natural number
n.
The above argument in the inductive step is the result of some rough analysis.
This analysis need not be described in the solution. The argument given in the
solution above should be sucient. The reader need not know how the writer
was able to formulate his proof. All that matters is that the argument used can
be easily understood and is indeed a valid proof. As an aid to understanding how
such arguments may be constructed, the method by which the above argument
was formulated is described as follows:
We need rst to clarify what needs to be proved. Let us write down the
statement P(n + 1):
a
n+1
= 3
(n+1)+2
(n + 1)
2
(n + 1) 1.
To prove this statement we must nd suitable connections between it and the
assumptions we have made in the inductive step; namely the statement P(n):
a
n
= 3
n+2
n
2
n 1.
In the question we are given a formula which relates a
n+1
to a
n
. We may use
this formula to express a
n+1
in terms of n with the help of the assumption P(n).
To complete the process we must then manipulate the resultant expression for
a
n+1
and write it in terms of n + 1. This should yield the statement P(n + 1).
These ideas were written down on a sheet of rough paper, thrashed out into
some form of argument, and then a number of revisions made, until a nal
version was arrived at. [Sometimes it helps to work directly on the conclusion.
For instance we may take note that (n + 1)
2
= n
2
+ 2n + 1. This observation
may help in the algebraic manipulations that must be performed in the proof.]
3.5 WARNING
A common mistake made by some students is to confuse the statement P(n)
which is needed for a proof by induction with an expression that occurs in the
problem. For instance in the rst example we denoted by P(n) the statement
a
n
= 7 2
n
3. P(n) should not be confused with the expression a
n
or
7 2
n
3. You should NOT write P(n) = a
n
or P(n) = 7 2
n
3 or even
P(n) = a
n
= 7 2
n
3. P(n) stands for a statement. A statement can be
translated into a full English sentence. The expressions a
n
and 7 2
n
3 do
56
NOT translate into full English sentences. It is meaningless to say that a
n
is
true, or that 7 2
n
3 is false. However an equation can be given a truth
value; an equation can be true or it can be false. For example 1
2
= 1 is a
true statement, and (1)
2
= 1 is a false statement. That is why in the rst
example we chose P(n) to be the equation a
n
= 7 2
n
3.
3.6 Worked Example
Prove by induction that, for every natural number n:
n

r=0
r(r + 1)(r + 2) =
1
4
n(n + 1)(n + 2)(n + 3).
Solution. For every natural number n, let P(n) be the statement:
n

r=0
r(r + 1)(r + 2) =
1
4
n(n + 1)(n + 2)(n + 3).
First Step: P(0) asserts that:
0

r=0
r(r + 1)(r + 2) =
1
4
0(0 + 1)(0 + 2)(0 + 3).
There is only one term in the sum; namely when r = 0. This term has value 0.
The value on the right hand side of the equation is also 0. Hence P(0) is true.
Inductive Step: Let n be any natural number and assume that P(n) is true.
Then:
n

r=0
r(r + 1)(r + 2) =
1
4
n(n + 1)(n + 2)(n + 3).
Therefore:
n+1

r=0
r(r + 1)(r + 2) =
n

r=0
r(r + 1)(r + 2) + (n + 1)[(n + 1) + 1][(n + 1) + 2]
=
1
4
n(n + 1)(n + 2)(n + 3) + (n + 1)(n + 2)(n + 3)
=
1
4
(n + 1)(n + 2)(n + 3)(n + 4)
=
1
4
(n + 1)[(n + 1) + 1][(n + 1) + 2][(n + 1) + 3].
Hence the statement P(n + 1) is true.
It follows by induction that the statement P(n) is true for every natural
number n.
Again the argument in the inductive step has been the result of thoughtful
analysis. The propositions P(n) and P(n+1) were written down and compared.
Firstly we know from the property of

that:
n+1

r=0
r(r + 1)(r + 2) =
n

r=0
r(r + 1)(r + 2) +n + 1[(n + 1) + 1][(n + 1) + 2].
57
Thus it remains to show by some algebraic manipulation that:
1
4
n(n + 1)(n + 2)(n + 3) + (n + 1)[(n + 1) + 1][(n + 1) + 2]
=
1
4
(n + 1)[(n + 1) + 1][(n + 1) + 2][(n + 1) + 3].
Note that P(n) does NOT denote the sum

n
r=0
r(r + 1)(r + 2), but the
complete equation

n
r=0
r(r +1)(r +2) =
1
4
n(n +1)(n +2)(n +2). If you need
some notation for the sum, use a dierent symbol, say for example S(n).
3.7 Generalizations of Proof by Induction
Sometimes we need to prove that a proposition P(n) is true not for all natural
numbers n but say for all natural numbers n greater than or equal to a given
natural number m, which need not be 0. In this case the rst step in the
argument would deal with the case n = m, rather than the case n = 0; i.e. we
would prove the proposition P(m). The inductive step would involve the proof
of P(n) = P(n + 1) for all n m. Thus proof by induction in this case takes
the form: If:
(a) P(m) is true;
(b) n : N [ n m P(n) = P(n + 1),
then P(n) is true for all natural numbers n greater than or equal to m.
This form of induction can be deduced from the inductive property of the
natural numbers with the set S dened to be the set of all natural numbers n
such that P(n +m) is true.
We mention another generalization, but will not deal with it further. The
Principle of Complete Induction states that, given a xed natural number m
and a proposition P(n) for every natural number n greater than or equal to m,
if:
(i) P(m) is true;
(ii) n : N [ n m (k : N [ m k n P(k)) = P(n + 1),
then P(n) is true for all natural numbers n greater than or equal to m.
The inductive step asserts that, if, for any natural number n greater than
or equal to m, P(k) is true whenever m k n, then P(n + 1) is true; i.e.
all the propositions P(m), P(m + 1), P(m + 2), . . ., P(n) together imply the
proposition P(n + 1). Again this form of induction may be deduced from the
inductive property of the natural numbers with in this case the set S dened to
be the set of all natural numbers n such that the propositions P(m), P(m+1),
P(m+ 2), . . ., P(m+n) are all true.
3.8 Worked Example
Prove by induction that, for every natural number n 4:
n

r=4
1
(r 2)(r 3)
=
n 3
n 2
.
58
Note that the general term of the sum is meaningless when r = 2 or r = 3.
Solution. For n 4, let P(n) be the statement:
n

r=4
1
(r 2)(r 3)
=
n 3
n 2
.
First Step: P(4) is the proposition:
4

r=4
1
(r 2)(r 3)
=
4 3
4 2
.
There is only one term in the sum and this has value
1
(42)(43)
=
1
2
. Now
43
42
=
1
2
. Hence P(4) is true.
Inductive Step: Suppose that n is a natural number greater than or equal
to 4 and assume that P(n) is true. Then:
n

r=4
1
(r 2)(r 3)
=
n 3
n 2
.
Then:
n+1

r=4
1
(r 2)(r 3)
=
n

r=4
1
(r 2)(r 3)
+
1
[(n + 1) 2][(n + 1) 3]
=
n 3
n 2
+
1
(n 1)(n 2)
=
1
(n 1)(n 2)
[(n 3)(n 1) + 1]
=
1
(n 1)(n 2)
[(n
2
4n + 3) + 1]
=
1
(n 1)(n 2)
(n
2
4n + 4)
=
1
(n 1)(n 2)
(n 2)
2
=
n 2
n 1
=
(n + 1) 3
(n + 1) 2
.
Hence P(n + 1) is true.
It follows by induction that P(n) is true for all natural numbers n 4.
59
Chapter 4
BASIC SET THEORY
4.1 Sets
A set is a collection of objects. In mathematics, we commonly use a letter or
some other symbol to denote a set. Some sets are so important, being used very
frequently that we x once and for all a particular notation for the set. Thus, for
example, we reserve the symbol Z to denote the set of all integers. If S denotes
a set and x denotes an object in S, we write x S and say that x belongs to S
or that x is a member or element of S. If an object x does not belong to the set
S we write x , S. Some symbols for sets are used in a transient way, discarding
them once we have nished with the context in which they occur. For example
in the present context of this paragraph let us assume that:
L denotes the set of all natural numbers less than 10;
H denotes the set of all members of the House of Commons
and S denotes the set of all railway stations in England.
As usual Z denotes the set of all integers. Then 5 is a member or element of the
set Z. Reading Station belongs to S. We may also write 5 Z, 12 , L,
2
5
, Z,
5 L and John Major H.
There are two ways of specifying a set. When the set contains only a nite
number of elements, we may list them between braces; i.e. curly brackets .
For example the expression 1, 4, 5, 7, 8 denotes the set containing the numbers
1, 4, 5, 6, 7 and 8. In such a representation of a set the order in which the
elements are listed does not matter. For example the sets 1, 2, 3 and 2, 3, 1
are the same. Also an element of a set need only be listed once; additional
listings of the same element are disregarded. Thus, for example, the expressions
1, 2, 3, 1, 2, 1, 3 and 1, 1, 1, 2, 2, 3, 3, 3, 3 are dierent ways of representing
the same set. Obviously the most economical way of representing such sets is
to list each element once. Sets represented in this way are said to be dened by
extension.
We may also dene a set by intension. In this case we specify some predicate
P(x) which is true precisely when x is a member of the set:
x [ P(x).
60
This expression represents the set of all objects x for which P(x) is true. Fre-
quently sets consist of objects of the same type. Thus:
x : X [ P(x)
denotes the set of all objects x of type X for which P(x) is true. For example
the set of all natural numbers x such that x
2
< 20 may be denoted by:
x : N [ x
2
< 20.
This set may also be expressed in form:
x [ x N x
2
< 20,
or even dened by extension; thus 0, 1, 2, 3, 4. One of the main uses of def-
inition by intension is in representing innite sets; i.e. sets with an innite
number of elements. Although all sets may be expressed in this way there is a
more sophisticated representation of a set which is of particular use in Computer
Science. This takes the form:
term declaration [ predicate,
and is referred to as set comprehension. For example, the set of all squares
less than 20 of natural numbers may be denoted by:
x
2
x : N [ x
2
< 20.
Again the elements of this set may be listed; 0, 1, 4, 9, 16. Using the more
basic notation, this set may also be denoted by:
x : N [ y : N x = y
2
x < 20.
In this case the predicate involves a quantier. Set comprehension also provides
a convenient way of representing the graph of a function as a set. For example
the graph of the function, sin x, with values of x from 0 to may be represented
as the set:
(x, sin x) x : R [ 0 x .
The pair (x, sin x) represents a typical point on the graph; i.e. is the coordinate
pair of such a point. Another example of the same kind involves the set of all
pairs consisting of candidates for a particular examination and the marks they
have achieved. Thus, if C denotes the set of candidates for the examination and
xAy means that candidate x has achieved the mark y, then the required data
is represented by the set:
(x, y) x : C; y : N [ xAy.
As another example, suppose that xV y means that the person x has visited
the town y. Suppose also that j stands for John and that T is the set of all
towns. The set of all towns which John has visited is given by:
y : T [ jV y.
61
If P denotes the set of all people, the data consisting of all people and the towns
that each person has visited is given by the set:
(x, y) x : P; y : T [ xV y.
Two sets, A and B, are said to be equal and we write A = B, if they contain
the same elements. Often the same set may be represented or labeled in more
than one way. In such cases we need the relation of equality to make it clear
that diering specications of a set give rise to the same collection of objects.
Thus, for example, 1, 4, 5, 7, 8 and 4, 8, 5, 1, 7 are dierent representations
of the same set; i.e.
1, 4, 5, 7, 8 = 4, 8, 5, 1, 7.
Again we may write:
x : N [ x
2
< 20 = 0, 1, 2, 3, 4.
If two sets, A and B, are not equal, we write A ,= B. In general a line
through a relational symbol indicates the negation of the relationship. Thus
A ,= B asserts that the statement A = B is false.
4.2 The Universal Set
Frequently when we deal with some problem in Set Theory we only consider
objects of some xed prescribed type, for example natural numbers or real
numbers. Thus, if we are dealing with sets whose elements are of a particular
type X, our sets take the form:
x : X [ P(x).
Note that X is a set. In this restricted context and only in this context we call
X the universal set. Every set under discussion within this context is a subset
of the universal set X.
4.3 Subsets of a Set
A set A is said to be a subset of a set B if every element of A is an element of
B. For example, 3, 5, 7 is a subset of 1, 3, 4, 5, 7. Note that N is a subset of
Z, because every natural number is an integer. We use the symbol to mean
is a subset of. Thus we may write:
3, 5, 7 1, 3, 4, 5, 7; N Z.
Obviously by denition, every set A is a subset of itself. A subset of A other
than A is said to be a proper subset of A. The symbol is used represent the
phrase is a proper subset of. Thus S A means that S is a proper subset of
A. Observe that:
3, 5, 7 1, 3, 4, 5, 7; N Z.
If we deal only with objects of a particular type, X, i.e. X is the universal set,
then the statement A is a subset of B is logically equivalent to the proposition:
x : X x A = x B.
62
4.4 Vacuous Truth
Given that Rockall is an uninhabited island, the proposition All inhabitants of
Rockall are left-handed is a true statement. Let P denote the set of all people,
let R denote the set of all inhabitants of Rockall and let L denote the set of all
left-handed people. Then the proposition translates into predicate logic as:
x : P x R = x L.
This statement is true, since for every person x the proposition:
x R = x L
is true. The reason for this is that, since there are no inhabitants of Rockall,
x R is false for every person x. Because the set R is empty, we say that
the proposition All inhabitants of Rockall are left-handed is a vacuous truth
or is true vacuously; i.e. is true because there are no inhabitants of Rockall;
the assertion does not apply to anybody. We say that the set R is empty. By
the denition of equality of sets two empty sets are equal. Thus there is one
and only one empty set which we denote by . Similarly the statement that
all the rivers on the moon contain sh is a true vacuously (the set of all rivers
on the moon is empty). Such statements although logically true have no real
content; they are evidently true within a vacuum. As a consequence of vacuous
truths, it follows that the empty set is a subset of every set. For any set A, the
proposition:
x : A x = x A
is vacuously true. This means by denition that A.
4.5 Set Operations
In the same way that we may combine two numbers to obtain a new number
using operations such as addition and multiplication, we may compose two sets
into a single set in various ways. Indeed there are many similarities in the
arithmetic of sets and ordinary arithmetic.
The union of two sets A and B is the set of all objects which belong to
one or both of the sets A, B. This set is denoted by A B. For example, if
A = 0, 3, 7, 8 and B = 2, 3, 6, 8, 9, then A B = 0, 2, 3, 4, 6, 7, 8, 9. In
general, we may dene:
A B = x [ x A x B.
Thus x A B if and only if x A x B; i.e. x A or x B.
The intersection of two sets A and B is the set of all objects which belong to
both A and B, and is denoted by A B. Thus, for example, if A and B are as
described in the previous paragraph, then A B = 3, 8. In general, we may
dene:
A B = x [ x A x B.
Thus x A B if and only if x A x B; i.e. x A and x B.
Since the operation of union may be applied to any two sets, given three
sets A, B and C, we may obtain the sets (AB) C and A(BC). Because
63
the connective satises the associative law; (P Q) R P (Q R), it
is easy to see that the operation of union is associative:
(A B) C = A (B C).
For:
x (A B) C x A B x C
(x A x B) x C
x A (x B x C)
x A x B C)
x A (B C).
We may therefore denote the union of three sets A, B and C by A B C.
The removal of the brackets in this case does not lead to an ambiguity. More
generally, the union of four or more sets does not depend on the order in which
the operation of union is applied and hence we do not need to use brackets to
distinguish this ordering. The same also holds for intersections; the operation
of is associative and so the repeated application of does not need the use
of brackets to indicate the order in which the operation is performed.
The logical connective may also be used to dene a set operation. Suppose
that A and B are two sets. Then AB denotes the set of all objects which belong
to A but not to B:
AB = x [ x A x B;
i.e.
AB = x [ x A x , B.
For example if A = 0, 3, 7, 8 and B = 2, 3, 6, 8, 9, then AB = 0, 7. Note
that, BA = 2, 6, 9. Thus, in general, AB and BA are dierent sets. AB
may be read as A minus B and is called the dierence of A and B.
Suppose that X is the universal set and that all sets under consideration are
subsets of X. Let A be a set (i.e. a subset of X). Then the dierence of X and
A is called the complement of A (in X) and is denoted by A

. Thus:
A

= x : X [ x A = x : X [ x , A.
For example, if R (the set of all real numbers) is the universal set in a particular
discussion and A is the set of all real numbers less than or equal to 2, then A

is the set of all real numbers greater than 2.


These set operations also explain why we need the empty set. For example,
if A = 1, 3, 4, 6 and B = 2, 7, 8, then A B is the set of all objects which
belong to both A and B. But there is no object which belongs to both A and
B and hence no object which belongs to A B. Thus A B is the empty set;
A B = . Without the concept of empty set, we would not be able to dene
in general the intersection of two sets.
64
4.6 Venn Diagrams
In this section we assume that the sets A, B, C etc. under discussion are subsets
of a universal set X. We can obtain an intuitively helpful idea of how sets behave
by drawing special diagrams called Venn diagrams. To represent the universal
set we draw a rectangular region in a plane:
The universal set is then represented by the points in the rectangular region.
The subsets of X are represented by circular or oval regions contained within
the rectangular region. The following diagram represents a general set A:
Note that the rectangular region is divided into 2 parts or subregions, called
atoms. These atoms represent the sets A and A

as shown by the shading in the


following Venn diagrams:
65
In the case of two sets A and B the following Venn diagram represents the
most general situation:
Note that there are 4 atoms which represent the sets A B, AB, BA and
(A B)

:
Note that the shaded region representing A B is region composed of or parti-
tioned into the atoms which represent the sets A B, AB and BA:
66
This suggests that:
A B = (A B) (AB) (BA).
Indeed this equation is an identity; i.e. it is satised by any pair of sets A and
B. Many set identities can be observed in this way from a Venn diagram and
can then be veried by more rigorous methods.
The general arrangement of three sets A, B, C is given in the Venn diagram:
In this case there are 8 atoms:
ABC, A(BC), B(CA), C(AB), (AB)C, BC)A,
C A)B, (A B C)

.
Sets obtained from these basic sets A, B, C, . . . using the operations of union,
intersection, dierence etc. may be represented by the shading of one or more
of these atoms. Thus for example AB C is represented by the shaded region
in the Venn diagram:
67
We must however temper the use of Venn diagrams with a warning. They should
be drawn in sucient generality for the problem in hand and should not exhibit
an assumption which is not warranted. Thus for example the following Venn
diagram although partitioning the rectangular region into 8 subregions makes
the assumption that (A B)C = :
Note that with this general arrangement, the atom C(A B) is represented
by the two non-overlapping shaded regions in the Venn diagram:
As noted above we may use Venn diagrams to suggest identities involving two
or more sets. Suppose that P and Q are sets which may be represented by the
shading of one or more atoms of three sets A, B, C. Then P Q is represented
by those shaded atoms which are common to both P and Q and P Q is
represented by all the shaded atoms associated with either P or Q. Thus for
example B is composed of the atoms:
BA C, (A B)C, (C B)A, A B C;
and C is composed of the atoms:
CA B, (A C)B, (C B)A, A B C;
Thus B C is composed of all the atoms listed for B and C; namely:
BAC, (AB)C, CAB, (AC)B, (C B)A, AB C;
Now A is composed of the atoms:
AB C, (A B)C, (A C)B, A B C;
Hence A (B C) is composed of the atoms:
(A B)C, (A C)B, A B C.
68
This analysis may be expressed in terms of Venn diagrams as follows:
A similar analysis for (A B) (A C) is:
69
By comparing the Venn diagrams it appears that:
(A B) (A C) = A (B C).
A proper proof of this identity is given as follows:
x (A B) (A C) x A B x A C
(x A x B) (x A x C)
x A (x B x C)
x A x B C
x A (B C).
4.7 Disjoint Sets
Two sets are said to be disjoint if they have no common element. Thus for
example, the following two sets are disjoint:
Reading, Windsor, Slough, London;
Oxford, Cambridge, Basingstoke, Birmingham, Salisbury.
On the other hand the sets:
George, John, Paul, Ringo;
Ringo, Pete
are not disjoint, since Ringo is an element common to both sets. Clearly two
sets A and B are disjoint if and only if A B = .
This denition extends to more than two sets. We say that three or more
sets are disjoint if no two of them have an element in common. Thus for example
the sets:
0, 2, 5, 10, 3, 8, 12, 4, 6, 20, 7, 11, 15, 18, 23, 24, 25, 26, 27, 28
are disjoint. We may represent disjoint sets on a Venn diagram by regions of
which no two overlap. Thus the atoms which represent the intersections of two
sets in the diagram are removed by shrinking their area to zero.
70
4.8 Cardinality
A set A is said to be nite if the number of elements in the set is nite; i.e. for
some natural number n, the number of elements in the set is n. For example,
the set John, Paul, George, Ringo is nite, since the number of elements in the
set is 4. Note that is nite since the number of elements in this set is 0.
However the sets N, Z and R are not nite; in this case we say that the sets are
innite. Thus a set is innite if it is not nite.
The number of elements in a nite set, A, is called the cardinality of the set
and is denoted by #A. If A and B are disjoint nite sets, then:
#(A B) = #A+ #B.
This principle clearly extends to more than two sets.
Let A and B be two not necessarily disjoint sets. By considering the atoms
in the case of two sets, we may observe that:
#A = #(A B) + #(AB);
#B = #(A B) + #(BA);
#(A B) = #(A B) + #(AB) + #(BA).
(For example A is the union of the disjoint sets - or the disjoint union of the
sets - A B and AB.) It follows that:
#(A B) + #(A B) = (#(A B) + #(AB) + #(BA)) + #(A B)
= (#(A B) + #(AB)) + (#(A B) + #(BA))
= #A+ #B.
4.9 Sets of Sets
A set is an object in its own right. Thus we may take sets as elements in other
sets. In this way we may form sets of sets. For example we may consider the
set:
A = N, Z, R.
Note that #A = 3. A is NOT the set of all real numbers; it does not contain
every natural number, every integer and every real number. Its elements are
sets not numbers. Similarly:
S = 1, 2, 4, 5, 8, 2, 3, 6, 3, 7, 7, 8, 9
is a set containing 4 elements; each element is itself a set. The set S does
NOT contain the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9. We may interpret sets of sets in
everyday life. For example a football league is a collection or set of clubs and
each club is a collection or set of players (and possibly support sta). Many large
organizations also have a similar structure, perhaps with many more layers, such
as regional, divisional, branch, department, sta. A region may be composed
of a number of divisions, each division has a number of branches, each branch
is divided into departments and at the lowest level each department contains a
number of sta.
71
4.10 The Power Set of a Set
If A is a set the power set of A is the set of all subsets of A, and is denoted by
PA. For example, if A = 1, 2, 5, then:
PA = , 1, 2, 5, 1, 2, 1, 5, 2, 5, 1, 2, 5.
Note that and A, itself, are subsets of A and hence are elements of PA.
In the language of sets, we adopt the convention that P binds more strongly
than the connectives , , . Thus, for example, PAPB means (PA) (PB).
4.11 Worked Example
Let A = 1, 2, 4, 5, 8, 9, B = 0, 1, 2, 7, 9, C = 3, 5, 6, 8 and D = 1, 3, 5, 7.
Represent each of the following sets by EITHER a list of its elements between
braces, with no element listed more than once, OR the symbol :
(i) (AB) C
(ii) A(B C)
(iii) x
2
3x x : N [ 5x < 21
(iv) x : Z [ x
2
A
(v) x : Z [ x
2
C
(vi) x : N [ x, x + 3 A
(vii) x : N [ x, x + 3 B
(viii) PDPC.
Solution. (i) AB = 4, 5, 8. Therefore (AB) C = 4, 5, 8 3, 5, 6, 8 =
3, 4, 5, 6, 8.
(ii) B C = 0, 1, 2, 3, 5, 6, 7, 8, 9. Therefore A(B C) = 4.
(iii) First we must identify the set x : N [ 5x < 21. It consists of all the
natural numbers x such that 5x < 21; i.e. the natural numbers 0, 1, 2, 3, 4.
Next we must evaluate the term x
2
3x for these natural numbers; thus:
0
2
3 0 = 0;
1
2
3 1 = 2;
2
2
3 2 = 2;
3
2
3 3 = 0;
4
2
3 4 = 4.
The required set must therefore contain these numbers, but listed no more
than once. Hence:
x
2
3x x : N [ 5x < 21 = 2, 0, 4.
72
(iv) We must determine all integers x such that x
2
A. The only complete
squares in Aare 1, 4, 9. Hence the possible values of x are 1, 1, 2, 2, 3, 3.
Thus:
x : Z [ x
2
A = 3, 2, 1, 1, 2, 3.
(v) In this case we must determine all integers x such that x
2
C. There are
no complete squares in the set C. Therefore:
x : Z [ x
2
C = .
(vi) In this example we require all natural numbers x so that x, x + 3 A.
Obviously every x satisfying this condition must belong to the set A. Hence
we determine those elements x A such that x + 3 A. Considering the
elements of A in turn we nd that the only elements x of A such that
x + 3 A are 1, 2, 5. Therefore:
x : N [ x, x + 3 A = 1, 2, 5.
(vii) In this case there are no elements of the set B such that x +3 B. Thus:
x : N [ x, x + 3 B = .
(viii) Now PD is the set of all subsets of D. The subsets of D are:
, 1, 3, 5, 7, 1, 3, 1, 5, 1, 7, 3, 5, 3, 7, 5, 7
1, 3, 5, 1, 3, 7, 1, 5, 7, 3, 5, 7, 1, 3, 5, 7.
Among these 16 sets only , 3, 5 and 3, 5 are subsets of C. Therefore:
PDPC = 1, 7, 1, 3, 1, 5, 1, 7, 3, 7, 5, 7
1, 3, 5, 1, 3, 7, 1, 5, 7, 3, 5, 7, 1, 3, 5, 7.
4.12 Worked Example
State the cardinalities of the following sets:
(a) 1 + 3, 3 2, 6 2, 2 + 7, 4 + 9, 5 1, 5 + 4.
(b) 1, 2, 1, 3, 2, 4, 4, 5, 6.
(c) 1, 2 2, 3, 4, 2, 3, 41, 2, 1, 4 2, 3, 3, 4, 5 1, 3, 4, 6,
3, 4, 5 2, 3.
(d) 1, 2, 3, 1, 2, 4, 2, 4, 51, 3, 4, 4, 5, 6, 4, 1, 2.
Solution. (a) The cardinality of this set is NOT 7. Since 1 + 3 = 4, 3 2 = 1,
6 2 = 4, 2 + 7 = 9, 4 + 9 = 13, 5 1 = 4 and 4 + 5 = 9, the set contains
only the 4 elements 1, 4, 9, 13. Thus the cardinality is 4.
(b) The elements of this set are themselves sets, NOT the numbers within these
sets. The cardinality of the given set is therefore 4.
73
(c) The elements of this set are again sets. In this case we need to clarify what
elements these sets contain. Indeed we have:
1, 2 2, 3, 4 = 1, 2, 3, 4
2, 3, 41, 2 = 3, 4
1, 4 2, 3 = 1, 2, 3, 4
3, 4, 5 1, 3, 4, 6 = 3, 4
3, 4, 5 2, 3 = 2, 3, 4, 5
Indeed there are only 3 distinct sets among these 5 sets; namely 1, 2, 3, 4,
3, 4 and 2, 3, 4, 5. Thus the cardinality of the given set is 3.
(d) Since 1, 2, 4 = 4, 1, 2, there are only two of the three elements in the
set 1, 2, 3, 1, 2, 4, 2, 4, 5 which are not elements in the subsequent
set 1, 3, 4, 4, 5, 6, 4, 1, 2; namely the elements 1, 2, 3 and 2, 4, 5.
Thus the cardinality of the given set is 2.
4.13 Worked Example
Many sentences in English often use collective words; words which represent
collections or sets of objects. Discussions about these objects can then be for-
mulated mathematically using set theory. Suppose for example that:
A is the set of all houses which have burglar alarms,
B is the set of all houses in Berkshire,
C is the set of all houses which have central heating,
D is the set of all detached houses,
G is the set of all houses which have double glazing.
Using only (some or all of) the symbols:
A, B, C, D, G, , , , , =, ,=, , (, ), =
write down expressions for the following sets and statements:
(a) The set of all detached houses in Berkshire which have central heating.
(b) The set of all houses in Berkshire which have neither central heating nor
double glazing.
(c) All detached houses in Berkshire have burglar alarms or double glazing or
both.
(d) There is at least one house in Berkshire which has central heating but not
double glazing.
(e) If all houses in Berkshire have central heating, then all detached houses in
Berkshire must have central heating.
Solution. (a) The set of all detached houses is D, the set of all houses in Berk-
shire is B and the set of all houses with central heating is C. Therefore
the set of all detached houses in Berkshire which have central heating is
D B C.
74
(b) The set of all houses which have central heating or double glazing or both is
C G. A house in Berkshire which does not have central heating or double
glazing belongs to the set B but not to the set CG. Therefore the required
set is B(C G).
(c) A house has a burglar alarm or double glazing or both if it belongs to the
set A G. A detached house in Berkshire belongs to the set D B. The
statement therefore asserts that an element of D B belongs to A G; i.e.
D B is a subset of A G:
D B A G.
(d) A house in Berkshire with central heating belongs to the set B C. If it
does not also have double glazing it cannot belong to G. Thus such a house
belongs to the set (B C)G. Hence the statement asserts that this set is
not empty; i.e:
(B C)G ,= .
(e) The statement all houses in Berkshire have central heating translates into
the statement B C. The statement all detached houses in Berkshire
have central heating similarly translates into D B C. Thus the full
statement asserts:
B C = D B C.
4.14 Worked Example
As before instead of using letters to denote objects such as sets we may use
words or word combinations. For example suppose that the expression Student
denotes the set of all students in the University of Reading and that the following
expressions denote subsets of Student:
mathematician, physicist, chemist, computer-scientist,
St-Andrew, St-George, St-Patrick, Wantage,
soccer-player, tennis-player.
Using only (some or all of) the above names for subsets of Student and the
following symbols:
, , , , =, ,=, , (, ), =
write down expressions for the following subsets of Student and statements:
(a) The set of all Chemistry students in St. Andrews Hall.
(b) The set of all Physics students in St. Georges Hall who do not play soccer
or tennis.
(c) No computer Science students live in St. Patricks Hall.
(d) All Mathematics students and all Computer Science students live in St.
Patricks or Wantage Hall.
(e) If all Mathematics students in St. Patricks Hall play soccer, then those in
Wantage Hall will have to play it too.
75
Solution. (a) The set of all Chemistry students in St. Andrews Hall is the set
of all those students who belong to both the sets chemist and St-Andrew. In
other words the set is chemist St-Andrew.
(b) Similarly the set of all Physics students in St. Georges Hall is the set
physics St-George. The set of students who play either soccer or tennis
is set of students who belong to one or both of the sets soccer-player and
tennis-player; i.e. the set soccer-player tennis-player. Thus the set of all
Physics students in St. Georges Hall who do not play soccer or tennis is:
(physicist St-George)(soccer-player tennis-player).
(c) The set of Computer Science students who live in St. Patricks Hall is the
set computer-scientist St-Patrick The statement asserts that there are no
students in this set; i.e:
computer-scientist St-Patrick = .
(d) The set of all Mathematics students and all Computer Science students is the
union of the set mathematician and the set computer-scientist. Similarly the
set of all students who live in St. Patricks Hall or Wantage Hall is the union
of the set St-Patrick and the set Wantage. The statement therefore asserts
that every element of the set textsfmathematician computer-scientist is
an element of the set St-Patrick Wantage; i.e:
mathematician computer-scientist St-Patrick Wantage.
(e) The set of all Mathematics students who live in St. Patricks Hall is the set
mathematician St-Patrick. The statement all mathematics students in St.
Patricks Hall play soccer translates into:
mathematician St-Patrick soccer-player.
Similarly the statement all mathematics students in Wantage Hall play
soccer translates into:
mathematician Wantage soccer-player.
Therefore the given statement may be expressed as:
mathematician St-Patrick soccer-player
= mathematician Wantage soccer-player.
76
77
Chapter 5
RELATIONS
5.1 Ordered Pairs
In many situations we need to consider pairs of objects arranged in a denite
order. If x and y are two objects, we denote the ordered pair consisting of
these objects by (x, y). The brackets indicate that the objects listed between
them are ordered. Thus the expression (x, y) represents the ordered pair of the
objects x and y with x placed rst and y placed second. If the objects x and
y are distinct then the ordered pair (x, y) is dierent from the ordered pair
(y, x). They are the same only when the objects x and y are the same. For
example a game between two soccer teams may be represented by an ordered
pair in which the team placed rst is the home team. Thus an international
between England and Scotland played at Wembley may be represented by the
pair (England, Scotland). Similarly, if England won the game by 2 goals to
1 the score may also be represented by the ordered pair (2, 1). However, if
Scotland won by 2 goals to 1, the score would be represented by the ordered
pair (1, 2). Another well known example to students of Mathematics is the
ordered pair (x, y) of coordinates of a point in a plane relative to particular
coordinate axes drawn in the plane. In the usual orientation of the axes x
represents the coordinate in the direction of the horizontal (i.e. x) axis and y
represents the coordinate in the direction of the vertical (i.e. y) axis.
Denition. When considering an ordered pair (x, y), we shall say that:
x is the rst element of the ordered pair;
y is the second element of the ordered pair.
5.2 Equality of Ordered Pairs
(x, y) and (p, q) are regarded as the same ordered pair and are thus said to be
equal if x and p are the same object (we may write x = p) and y and q are
the same object (y = q). If (x, y) and (p, q) are equal we write (x, y) = (p, q).
Thus (x, y) = (p, q) if and only if x = p and y = q. If the objects u and v are
not the same we say that they are not equal and write u ,= v. In particular
(x, y) ,= (p, q) if and only if x ,= p or y ,= q. Note that the justication for this
78
statement is purely logical:
(x, y) ,= (p, q) ((x, y) = (p, q))
(x = p y = q)
x = p y = q
x ,= p y ,= q.
5.3 Cartesian Product of Sets
Let A and B be sets. Then the set of all ordered pairs (x, y) with x A and
y B is called the Cartesian product of A and B and is denoted by AB. For
example suppose that A = f, g and B = p, q, r. Then:
AB = (f, p), (f, q), (f, r), (g, p), (g, q), (g, r).
Note that, since #A = 2 , #B = 3 and #(AB) = 6:
#(AB) = #A#B.
This equation holds in general for nite sets. For if #A = m and #B = n, then,
for each x A, there exist n dierent pairs of the form (x, y) with y B (one for
every such y). Hence there are mn dierent pairs in AB; i.e. #(AB) = mn.
5.4 Relations
Let A be the set of all students in a certain university and let B be the set
of all subjects taught in that university. Consider the relationship between a
student at the university and the subjects which the student studies at the
university. This relationship may be described by collecting together all the
pairs (x, y) in A B where x is a student and y is a subject which the stu-
dent studies. Since not all students usually study all subjects the collection of
all such pairs will form a subset R of A B. The subset R characterizes the
relationship. For example, if John is a student of the university and he stud-
ies Mathematics and Computer Science, but not Statistics, then the ordered
pairs (John, Mathematics) and (John, Computer Science) belong to R, but not
(John, Statistics), which nevertheless belongs to AB. Only the pairs in AB
which bear the relationship belong to R.
More generally a relation between a set A and a set B is a subset of AB.
Note that if A and B are distinct sets then A B is dierent from B A.
Thus a relation between A and B need not be a relation between B and A. In
the example considered in the previous paragraph the relationship of subject to
student who studies that subject is dierent from the relationship of student to
subject which the student studies. Similarly the relationship of natural father
to daughter is dierent from the relationship of daughter to natural father. A
father may have more than one daughter, but a daughter has precisely one
father. In the relationship of daughter to natural father, we may regard the
daughter as the subject of the relationship and the father as the object of the
relationship.
79
We may express the fact that R is a relation between the set A and the
set B in other ways. Because R is a subset of A B, it is a member of the
power set P(AB); i.e. it is an object of type P(AB). Thus we may write
R : P(A B) for the statement that R is a relation between A and B. An
equivalent functional notation is:
R : A B.
This function notation provides an alternative to the ordered pair (x, y):
x y,
which reads x maps to (or into) y. Thus the statement which asserts that,
under the relation R, x maps to y is equivalent to the statement that (x, y) R.
If (x, y) R, we may also say that x is R-related to y. Thus a relation R between
sets A and B may be regarded as a binary predicate in predicate logic and hence
we may use the notation R(x, y) or xRy to mean that x is R-related to y. In
this interpretation x is an object of type A and y is an object of type B and
the proposition R(x, y) (or xRy) is true if and only if (x, y) R. Conversely
a binary predicate D(x, y) which governs objects x of type A and objects y of
type B may be regarded as a relation D between A and B such that (x, y) D
if and only if D(x, y) is true.
5.5 Relations on a Set
Let A be a set. Then a relation R on A is a subset of A A; i.e. a relation
between A and A. For example, let A = 1, 2, 3, 4, 5. Then:
R = (1, 2), (1, 3), (1, 5), (2, 3), (4, 2), (4, 4), (5, 2)
= 1 2, 1 3, 1 5, 2 3, 4 2, 4 4, 5 2
is a relation on A.
Again for example a relation R on a set A may be regarded as equivalent to a
binary predicate R(x, y) or xRy which governs objects x, y of type A. (x, y) R
if and only if R(x, y) is true. For example, the binary predicate < which governs
objects of type R is a relation on R. As a relation < is the subset of R R
consisting of all pairs (x, y) of real numbers such that x < y.
An important relation on a set A is the relation I dened by:
I = (x, y) x, y : A [ x = y.
This relation is called the identity relation on A. Note that, if x and y are
elements of A, then (x, y) I if and only if x = y. We usually denote the
identity relation on a set A by id A.
As is the practice of using a word or word combination to denote a set
or a predicate, we may use them to denote relations. For example the set of
all students in a particular university might be denoted by the word Student
and the set of subjects taught in that university might be denoted by the word
Subject. Then the relation of student to subject which the student studies might
be denoted by the word studies. More precisely we write:
studies : Student Subject.
80
The statement that John studies Mathematics would be expressed by saying
that (John, Mathematics) studies, or by writing John studies Mathematics.
Similarly the relation of one person being the parent of another may be denoted
by:
is-parent-of : Person Person,
where Person denotes the set of all people. The statement that John is parent
of Mary may be expressed in the form:
(John, Mary) is parent of,
or:
John is-parent-of Mary.
5.6 Domain and Range of a Relation
If R is a relation between the sets A and B, the set:
x : A [ (y : B (x, y) R)
is called the domain of R and is denoted by domR, and the set:
y : B [ (x : A (x, y) R)
is called the range of R and is denoted by ran R. Thus an object belongs to
domR if and only if it is the rst element of at least one ordered pair which
belongs to R, and an object belongs to ran R if and only if it is the second
element of at least one ordered pair which belongs to R.
Example. Suppose that a small private university has just 6 students named:
Alice, Bill, John, Mary, Ted and Anne
and oers courses in just 7 subjects; namely:
Geography, History, Mathematics, Physics, Chemistry, French and
German.
Suppose that A is the set of students and B is the set of subjects. Suppose that
the subjects studied by each student are as follows:
Alice studies Mathematics, Physics and Chemistry.
Bill studies History and Mathematics.
John studies no subject.
Mary studies French, German and History.
Ted studies only Physics.
Anne studies no subject.
Suppose that R : A B is the relation which tells us which students study
which subjects. Thus:
R = (Alice, Mathematics), (Alice, Physics), (Alice, Chemistry)
(Bill, History), (Bill, Mathematics), (Mary, French)
(Mary, German), (Mary, History), (Ted, Physics).
81
Then domR is the set:
Alice, Bill, Mary, Ted,
because Alice, Bill, Mary and Ted are the objects which are placed rst in at
least one ordered pair belonging to R. Similarly ran R is the set:
Mathematics, Physics, Chemistry, History, French, German,
since Mathematics, Physics, Chemistry, History, French and German are placed
second in at least one ordered pair contained in R. Note that there are two
elements of A which are not in domR; namely John and Anne. There is just
one element of B which is not in ran R; namely Geography.
5.7 The Inverse of a Relation
Consider the relation R of student to subject as given in the previous example.
We may reverse the roles of student and subject in this relation to obtain the
relation that species which subject is studied by which student. We denote
this relation by R

: B A. Thus:
R

= (Mathematics, Alice), (Physics, Alice), (Chemistry, Alice)


(History, Bill), (Mathematics, Bill), (French, Mary)
(German, Mary), (History, Mary), (Physics, Ted).
R

is called the inverse of R. Note that domR

= ran R and ran R

= domR.
For:
domR

= Mathematics, Physics, Chemistry, History, French, German


= ran R;
ran R

= Alice, Bill, Mary, Ted = domR.


In general, if R : A B is a relation, then the inverse of R is the relation
R

: B A dened by the rule that, if x A and y B, then:


(y, x) R

if and only if (x, y) R.


(i.e. y is R

-related to x if and only if x is R-related to y) and:


domR

= ran R; ran R

= domR.
For:
y domR

y B x : A (y, x) R

y B x : A (x, y) R
y ran R,
and:
x ran R

x A y : B (y, x) R

x A y : B (x, y) R
x domR.
82
5.8 Relational Image
Let R : A B be a relation and let E be a subset of A. Then R([E[) denotes
the set of those elements of B to which at least one element of E is R-related.
Thus with each subset E of A we associate a subset R([E[) of B. Note that, for
any y B, y R([E[) if and only if there exists x E such that (x, y) R.
R([E[) is called the relational image of E through R or the R-image of E.
Example. Let A = 1, 2, 3, 4, 5, 6, 7, 8 and let B = a, b, c, d, e, f, g, h, k, where
a, b, c, d, e, f, g, h, k are distinct objects. Suppose that the relation R : A B is
given by:
R = (1, d), (2, b), (2, g), (3, e), (3, h), (5, d), (5, e), (5, k),
(6, a), (6, b), (6, g), (6, k), (8, e), (8, h), (8, k).
Suppose that E is the subset 3, 5, 7, 8 of A. Then:
no element of E is R-related to a;
no element of E is R-related to b;
no element of E is R-related to c;
the element 5 of E is R-related to d, since (5, d) R;
the elements 3, 5, 8 of E are R-related to e, since (3, e), (5, e), (8, e) R;
no element of E is R-related to f;
no element of E is R-related to g;
the elements 3, 8 of E are R-related to h, since (3, h), (8, h) R;
the elements 5, 8 of E are R-related to k, since (5, k), (8, k) R.
It follows that d, e, h, k is the set of all elements of B to which at least one
element of E is R-related. Thus:
R([E[) = d, e, h, k.
Similarly with any subset F of B we may associate the subset R

([F[)of
A. Then, if x A, x R

([F[) if and only if there exists y F such that


(y, x) R

; i.e. such that (x, y) R.


Example. Let R : A B be the relation as dened in the previous example.
Let F = a, b, c, g, h. Then:
1 is not R-related to any element of F;
2 is R-related to the elements b, g of F, since (2, b), (2, g) R;
3 is R-related to the element h of F, since (3, h) R;
4 is not R-related to any element of F;
5 is not R-related to any element of F;
6 is R-related to the elements a, b, g of F, since (6, a), (6, b), (6, g) R;
7 is not R-related to any element of F;
8 is R-related to the element h of F, since (8, h) R.
Therefore 2, 3, 6, 8 is the set of all elements of A which are R-related to at
least one element of F. Thus:
R

([F[) = 2, 3, 6, 8.
Note that in answering a question of this type it is not necessary to be as
detailed as we have been in this and the previous example. All that is needed,
83
for instance to determine R

([F[), is to mentally pick out the pairs in R whose


second element belongs to F and then list without repetitions the rst elements
of these pairs.
To recap, if R : B is a relation, E is a subset of A and F is a subset of B,
then:
R([E[) = y : B [ x : E (x, y) R;
R

([F[) = x : A [ y : F (x, y) R.
5.9 Restrictions of Relations
Let R : A B be a relation, let E be a subset of A and let F be a subset of
B. Then we may dene the following subsets of R:
E R = (x, y) : R [ x E;
E R = (x, y) : R [ x , E;
R F = (x, y) : R [ y F;
R F = (x, y) : R [ y , F.
Note that, since these are necessarily subsets of AB, they are relations between
A and B. Because they are subsets of R, they are called restrictions of R. More
specically:
E R is called the domain restriction of R to E;
E R is called the domain anti-restriction of R to E;
R F is called the range restriction of R to F;
R F is called the range anti-restriction of R to F.
Note that:
E R = (A E) R; R F = R (B F).
Example. Let A = 1, 2, 3, 4, 5, 6, 7, 8 and let B = a, b, c, d, e, f, g, h, k, where
a, b, c, d, e, f, g, h, k are distinct objects. Suppose that the relation R : A B is
given by:
R = (1, d), (2, b), (2, g), (3, e), (3, h), (5, d), (5, e), (5, k),
(6, a), (6, b), (6, g), (6, k), (8, e), (8, h), (8, k).
Suppose that E is the subset 3, 5, 7, 8 of A and F is the subset a, b, c, g, h
of B. Then:
E R = (3, e), (3, h), (5, d), (5, e), (5, k), (8, e), (8, h), (8, k);
E R = (1, d), (2, b), (2, g), (6, a), (6, b), (6, g), (6, k);
R F = (2, b), (2, g), (3, h), (6, a), (6, b), (6, g), (8, h);
R F = (1, d), (3, e), (5, d), (5, e), (5, k), (6, k), (8, e), (8, k).
84
5.10 Set Operations on Relations
Because relations are sets, we may apply the normal set operations , , on
relations. Thus, if R and S are relations between sets A and B, then so are
R S, R S and R S.
Example. Suppose that we are conducting a survey of the use of public transport
in 1996 by people living in Hampshire. Let H be the set of all people living
in Hampshire and let D be the set of all days in 1996. Let B be the set of all
ordered pairs (x, y) such that x is a person living in Hampshire and y is a day in
1996 on which x traveled by bus. Let T be the set of all ordered pairs (x, y) such
that x is a person living in Hampshire and y is a day in 1996 on which x traveled
by train. Thus B : H D and T : H D are relations. Then B T, B T,
BT and T B are relations between H and D. The ordered pair (x, y) belongs
to B T if and only if (x, y) belongs to B and to T; i.e. x is a person living
in Hampshire who traveled by both bus and train on the day y in 1996. Now
dom(BT) is the set of all people living in Hampshire who traveled by both bus
and train on the same day in 1996. Note that dom(BT) (domB)(domT).
These sets need not be the same, since a person living in Hampshire may travel
by bus on some day in 1996 and by train on some day in 1996, but not by both
bus and train on the same day in 1996. There are many properties of this kind
that may be investigated .
5.11 Worked Example
Suppose that:
A is the set of all students in the University;
B is the set of all books belonging to the University Library;
E is the set of all overseas students in the University;
F is the set of all works of ction belonging to the library;
R : A B is the set of all ordered pairs (x, y) such that x is a
student in the university and y is a book which x borrowed from the
library during last term;
D : A B is the set of all ordered pairs (x, y) such that x is a
student in the university and y is a book from the library which x
damaged last term.
In the phrases and statements which follow we use, in an obvious way, simplied
words or phrases to denote the objects of these sets. Thus, for example, the
word book refers to a book belonging to the University Library. Using only
(some or all of) the symbols:
A, B, D, E, F, R, , , =, , (, ),

, dom, ran, ([, [), , , , ,


write down expressions for the following sets and statements:
(a) The set of all ordered pairs (x, y) such that x is a student and y is a book
which x borrowed and damaged.
(b) The set of all ordered pairs (x, y) such that x is a student and y is a book
which x damaged without borrowing it.
85
(c) The set of all ordered pairs (x, y) such that x is an overseas student and y
is a work of non-ction which x borrowed.
(d) The set of all works of ction which were borrowed by at least one overseas
student.
(e) The set of all students who damaged at least one book without borrowing
it.
(f) The set of all books borrowed by students who damaged at least one book.
(g) All works of non-ction were damaged by students.
(h) Every overseas student borrowed at least one work of ction.
(i) No book was borrowed by both a home (i.e. non-overseas) student and an
overseas student.
Solution. (a) A student x borrowed a book y if and only if (x, y) R. Similarly
x damaged y if and only if (x, y) D. Thus x borrowed and damaged y if
and only if (x, y) R and (x, y) D; i.e. (x, y) R D. Thus R D is
the set of all ordered pairs (x, y) such that x is a student and y is a book
which x both borrowed and damaged.
(b) Let x be a student who damaged but did not borrow the book and let y be
a book. Then x did not borrow y if and only if (x, y) , R. Then by the
arguments used in part (a) x damaged but did not borrow y if and only
if (x, y) D and (x, y) , R; i.e. (x, y) D R. Thus the required set is
D R.
(c) x is an overseas student and y is a work of non-ction which x borrowed if
and only if (x, y) R, x E and y , F. There are two ways of combining
these conditions; either:
(x, y) R x E y , F ((x, y) R x E) y , F
(x, y) E R y , F
(x, y) (E R) F
or:
(x, y) R x E y , F x E ((x, y) R y , F)
x E (x, y) R F
(x, y) E (R F).
Thus the required set can be expressed as (E R) F or as E (RF).
Note that, in general, these restrictions are the same. Hence we may express
the set simply as E R F.
(d) y is a book which was borrowed by at least one overseas student if and only
if there exists x E such that (x, y) R; i.e. y R([E[). y is a work of
ction if and only if y F. Thus the required set is R([E[) F.
86
(e) From part (b), D R is the set of all ordered pairs (x, y) such that x is
a student and y is a book which x damaged without borrowing it. The
set of all students who damaged at least one book without borrowing it is
therefore the domain of the relation D R; i.e. the set dom(D R).
(f) The set of all students who damaged at least one book is clearly the domain
of the relation D; i.e. the set domD. y is a book borrowed by such a
student if and only if there exists x domD such that (x, y) R; i.e.
y R([ domD[). Thus the required set is R([ domD[).
(g) The set of all works of non-ction is B F. y is a book damaged by at least
one student if and only if there exists x A such that (x, y) D; i.e. if
and only if y ran D. Therefore the set of all books damaged by at least
one student is ran D. The statement asserts that every element of B F is
an element of ran D; i.e. B F ran D.
(h) x is a student who borrowed at least one work of ction if and only if there
exists y F such that (x, y) R; i.e. x R

([F[). The statement therefore


asserts that every element in E is an element in R

([F[); i.e. E R

([F[).
(i) y is a book borrowed by an overseas student if and only if there exists x E
such that (x, y) R; i.e. y R([E[). Thus the set of all books borrowed
by overseas students is R([E[). Similarly, since the set of home students is
A E, the set of all books borrowed by home students is R([A E[). The
statement therefore asserts that R([E[) R([A E[) = .
5.12 Relational Overriding
A relation (i.e. a set of ordered pairs) might constitute information which is kept
on paper or in a computer database or both. For instance a University must
keep records of which subjects each of its students is studying. This information
might change and the records must then be altered. Thus the original relation
is overridden with new information which therefore transforms it into a new
relation.
Lets take another example. A booksellers shop tries to keep records of
potential customers and the subjects in which they are believed to be interested
so that each customer can be informed of all new books on appropriate subjects.
For the sake of simplicity suppose that there are just nine customers called
Anne, Bill, Charlie, Fred, George, Jane, Mary, Sue and Tom kept on record and
that the bookseller retails books on just eight subjects; namely Art, Botany,
Chemistry, Gardening, History, Politics, Sport and Travel. Suppose that the
booksellers records indicate that:
Anne is interested in Botany, Gardening and Travel;
Bill is interested in Botany, Gardening and Sport;
Fred is interested in Art and Sport;
George is interested in Travel;
Sue is interested in Gardening and Sport;
Tom is interested in Sport.
Let A be the set of all customers and let B be the set of all subjects. Then the
booksellers records constitute a relation R : A B. An ordered pair (x, y)
87
belongs to R if and only if x A, y B and the customer x is believed to be
interested in the subject y. Thus:
R = (Anne, Botany), (Anne, Gardening), (Anne, Travel),
(Bill, Botany), (Bill, Gardening), (Bill, Sport),
(Fred, Art), (Fred, Sport), (George, Travel),
(Sue, Gardening), (Sue, Sport), (Tom, Sport).
The bookseller now wishes to update the records and therefore writes to each
customer requesting an up-to-date list of the subjects in which he or she is
interested. Only Anne, Charlie, Mary, Sue and Tom reply, stating that:
Anne is interested in Chemistry and Gardening;
Charlie is interested in Art, Botany and Chemistry;
Mary is interested in Gardening and Travel;
Sue is interested in Gardening and Sport;
Tom is interested in Art and Travel.
This results in another relation S : A B. An ordered pair (x, y) belongs to
S if and only if x is a customer who sent a reply and y is one of the subjects of
interest listed in that reply. Thus:
S = (Anne, Chemistry), (Anne, Gardening), (Charlie, Art),
(Charlie, Botany), (Charlie, Chemistry), (Mary, Gardening),
(Mary, Travel), (Sue, Gardening), (Sue, Sport),
(Tom, Art), (Tom, Travel).
Note that domS = Anne, Charlie, Mary, Sue, Tom. The booksellers records
are amended so that they now contain the set of ordered pairs:
(Anne, Chemistry), (Anne, Gardening), (Bill, Botany),
(Bill, Gardening), (Bill, Sport), (Charlie, Art)
(Charlie, Botany), (Charlie, Chemistry), (Fred, Art),
(Fred, Sport), (George, Travel), (Mary, Gardening),
(Mary, Travel), (Sue, Gardening), (Sue, Sport),
(Tom, Art), (Tom, Travel).
These records thus form a new relation, denoted by RS, and called the relation
R overridden by S. Note that the ordered pairs in R S consist of:
(i) the ordered pairs in S;
(ii) the ordered pairs in R whose rst elements are not in domS.
For example the ordered pair (Fred, Art) belongs to R, but its rst element,
Fred, is not in domS. Thus (Fred, Art) remains in R S.
R S is obtained from R by removing all pairs (x, y) from R in which the
rst element, x, belongs to domS and replacing them by the pairs in S. Thus
we may dene:
R S = S ((domS) R).
This denition applies to any two relations R : A B and S : A B between
the same sets A and B. Thus (x, y) RS if and only if, either (x, y) S, or
(x, y) R and x , domS.
88
5.13 Worked Example
Let A = 0, 1, 2, 3, 4, 5, 6, 7, 8 and let B = a, b, c, d, e, f, where a, b, c, d, e, f
are distinct objects. Let R : A B and S : A B be the relations given by:
R = (0, c), (2, a), (2, b), (3, a), (3, c), (3, d), (5, d), (7, d), (7, f);
S = (2, b), (2, d), (2, f), (4, a), (4, b), (7, a), (8, a), (8, c).
Represent the set RS by a list of its elements between braces, with no element
listed more than once.
Solution. First note that all the pairs in S belong to R S. Now:
domS = 2, 4, 7, 8.
Therefore 0, 1, 3, 5, 6 are the elements of A which are not in domS. Hence the
pairs, (x, y), in R with x , domS are:
(0, c), (3, a), (3, c), (3, d), (5, d).
Thus:
R S = (0, c), (2, b), (2, d), (2, f), (3, a), (3, c), (3, d),
(4, a), (4, b), (5, d), (7, a), (8, a), (8, c).
We may list the elements of RS with a simple mental process which considers
the elements of A = 0, 1, 2, 3, 4, 5, 6, 7, 8 in turn. First consider 0. Now 0 ,
domS and there is only one pair in R with rst element 0; namely (0, c). Thus
we put (0, c) in the list. Next we consider 1. There is no pair in either R or
S with rst element 1. Hence we proceed to the next element 2 of A. Now
2 domS. Thus we list all the pairs of S with rst element 2; namely (2, b),
(2, d) and (2, f). Next we consider the element 3 of A. Now 3 , domS and
there are three pairs in R with rst element 3; namely (3, a), (3, c) and (3, d).
Thus we add these pairs to the list. We continue in this way until we have
exhausted all the elements of A.
5.14 Composition of Relations
Suppose that A, B, C are sets and R : A B and S : B C are relations.
Then we can construct a relation R
o
9
S : A C by the rule:
(x, z) R
o
9
S if and only if there exists an object y B such that
(x, y) R and (y, z) S or equivalently xRy and ySz.
The relation R
o
9
S is called the composition of R and S. Note that if (x, z)
belongs to R
o
9
S, then there exists an element y B such that (x, y) R and
(y, z) S. In particular y ran R and y domS. Thus y ran R domS.
Conversely, if y ran RdomS, then (x, z) R
o
9
S if x is R-related to y and y
is S-related to z. Thus to determine the pairs (x, z) in R
o
9
S, we rst determine
the set ran RdomS and then for each element y in this set determine all pairs
(x, z) such that x is R-related to y and y is S-related to z.
89
Example. Let:
A = 1, 2, 3, 4, 5, 6,
B = a, b, c, d, e, f, g, h
C = i, j, k, l, m, n,
where a, b, c, d, e, f, g, h, i, j, k, l, m, n are distinct objects. Let R : A B and
S : B C be relations given by:
R = (1, a), (1, b), (1, c), (1, e), (2, a), (3, b), (3, c), (5, c), (5, f), (5, h);
S = (a, j), (b, i), (b, j), (c, j), (c, l), (c, m), (d, l), (d, m), (e, m), (e, n), (h, n).
Then:
ran R = a, b, c, e, f, h;
domS = a, b, c, d, e, h.
Hence:
ran R domS = a, b, c, e, h.
Consider the element a. Then the elements 1, 2 are R-related to a and a is only
S-related to the element j. Thus the pairs (1, j), (2, j) are in R
o
9
S. Next 1, 3, are
R-related to b and b is S-related to the objects i, j. Thus (1, i), (1, j), (3, i), (3, j)
are in R
o
9
S. Note that (1, j) is already a member of R
o
9
S; we only count it
once. This means that we have found 5 elements of R
o
9
S at this stage. Now
1, 3, 5 are R-related to c and c is S-related to j, l, m. Thus the pairs:
(1, j), (1, l), (1, m), (3, j), (3, l), (3, m), (5, j), (5, l), (5, m)
are all in R
o
9
S. Next 1 is the only element R-related to e and e is S-related to
the elements m, n. Thus the pairs (1, m), (1, n) are objects of R
o
9
S. Finally 5
is the only element R-related to h and h is S-related to n. Thus (5, n) belongs
to R
o
9
S. Therefore collecting all the pairs of R
o
9
S together:
R
o
9
S = (1, i), (1, j), (1, l), (1, m), (1, n), (2, j), (3, i),
(3, j), (3, l), (3, m), (5, j), (5, l), (5, m), (5, n).
Alternatively, we may write down the elements of A which are R-related to
objects in domS; in this case: 1, 2, 3, 5. Then we proceed as follows:
Since (1, a) R and (a, j) S, (1, j) R
o
9
S;
Since (1, b) R and (b, i) S, (1, i) R
o
9
S;
Since (1, b) R and (b, j) S, (1, j) R
o
9
S;
Since (1, c) R and (c, j) S, (1, j) R
o
9
S;
Since (1, c) R and (c, l) S, (1, l) R
o
9
S;
Since (1, c) R and (c, m) S, (1, m) R
o
9
S;
Since (1, e) R and (e, m) S, (1, m) R
o
9
S;
Since (1, e) R and (e, n) S, (1, n) R
o
9
S;
Since (2, a) R and (a, j) S, (2, j) R
o
9
S;
Since (3, b) R and (b, i) S, (3, i) R
o
9
S;
90
Since (3, b) R and (b, j) S, (3, j) R
o
9
S;
Since (3, c) R and (c, j) S, (3, j) R
o
9
S;
Since (3, c) R and (c, l) S, (3, l) R
o
9
S;
Since (3, c) R and (c, m) S, (3, m) R
o
9
S;
Since (5, c) R and (c, j) S, (5, j) R
o
9
S;
Since (5, c) R and (c, l) S, (5, l) R
o
9
S;
Since (5, c) R and (c, m) S, (5, m) R
o
9
S;
Since (5, h) R and (h, n) S, (5, n) R
o
9
S.
Then listing these pairs without repetition we obtain the same set R
o
9
S.
Example. Let A be the set of all students in the University, B be the set of
all courses taught in the University in the academic year 1996/97 and let C
be all the days of that year. Suppose that R : A B be the relation which
tells us which student is taking which course and let S : B C be the re-
lation which tells us which course has a lecture on which day. Suppose that
John takes the course Discrete Mathematics and that there is a lecture in Dis-
crete Mathematics on January 20. Then (John, Discrete Mathematics) R
and (Discrete Mathematics, January 20) S. Then (John, January 20) R
o
9
S.
This relationship asserts that John has a lecture on January 20. Thus the
relation R
o
9
S : A C tells us which students take lectures on which days.
Example. Let A be the set of all customers of a particular bookseller and let
B be the set of all subjects of the books on sale by the bookseller. Let R :
A B be the relation which indicates which customers are interested in which
subjects. For example suppose that John is interested in Sport. John is a
customer of the bookseller and Sport is a subject covered by books on sale
by the bookseller. Then (John, Sport) R. Let C be the set of books in
a new consignment of books sent to the bookseller and let S : B C be
the relation which associates with each subject each book in the consignment
which is regarded as relevant to that subject. For example, suppose that the
consignment contains a book entitled The History of Sport, which is regarded
as relevant to both History and Sport. Then (History, The History of Sport)
and (Sport, The History of Sport) both belong to S. Consider the relation
R
o
9
S : A B. If the pair (x, z) belongs to this relation, then there exists a
subject y such that (x, y) R and (y, z) S. Thus x is a customer and x is
interested in subject y and z is a book in the new consignment which is relevant
to the subject y. The customer x may therefore wish to consider the book y for
purchase. Therefore the bookseller should inform the customer y that the book
z has now become available.
We will consider later special relations called functions. For such a relation
f : A B any element x A is f-related to one and only one element y in B.
We denote y by f(x). In particular domR = A. Suppose that R : A B and
S : B C are functions. Then R
o
9
S : A C is also a function. If x A,
then R(x) B and S(R(x)) C. Moreover (R
o
9
S)(x) = S(R(x)). It is natural
in the context of functions to use a notation for the composition of R and S
which keeps the same order as the notation S(R(x)). Indeed the composition
of the two functions R and S is usually denoted by S R. Thus, if x A, then
(SR)(x) = S(R(x)). For this reason the composition of two relations also may
use this backwards or reverse notation.
In considering the composition R
o
9
S : A C of two relations R : A B
and S : B C, the sets A, B, C need not be distinct. In particular, if C = A,
91
then R
o
9
S is a relation on A. It follows that the composition of two relations on
a set A is a relation on A. For example, if R : A A is a relation on A, then
so is the composition R
o
9
R.
As an operation the composition of relations is associative; i.e. if R : A B,
S : B C and T : C D are relations, then:
(R
o
9
S)
o
9
T = R
o
9
(S
o
9
T).
For:
(w, z) (R
o
9
S)
o
9
T y : C (w, y) R
o
9
S (y, z) T
y : C (x : B (w, x) R (x, y) S) (y, z) T
y : C; x : B (w, x) R (x, y) S (y, z) T
x : B; y : C (w, x) R (x, y) S (y, z) T
x : B (w, x) R (y : C (x, y) S (y, z) T
x : B (w, x) R (x, z) S
o
9
T
(x, z) R
o
9
(S
o
9
T).
Note that, if R : A B is a relation, then:
R
o
9
id B = R = id A
o
9
R.
5.15 The Directed Graph of a Relation on a Set
Let R : A A be a relation on the set A. If x, y A and (x, y) R, recall that
we may write x y. This suggests that the elements of A be represented by
points in a diagram with the pairs (x, y) R represented by arrows which start
at the points x and end at the points y; thus: The points are called
vertices and the arrows are called edges. The complete diagram is called the
directed graph of the relation. Fop example suppose that A = 0, 1, 2, 3, 4, 5, 6
and that R : A A is the relation on A given by the set:
R = (0, 1), (0, 4), (0, 5), (1, 2), (1, 4), (2, 0), (2, 2), (2, 5),
(3, 1), (3, 4), (4, 3), (6, 0), (6, 3).
The directed graph of R consists of seven vertices which represent the objects
0, 1, 2, 3, 4, 5, 6 of A and thirteen edges representing the pairs in R. The directed
graph of R therefore may be drawn as follows:
92
In this directed graph the edge represents the ordered pair (0, 1). The
other ordered pairs of R are represented in a similar way. In particular the
ordered pair (2, 2) is represented by the vertex 2 and an edge which starts at 2
and ends at 2. Such an edge is called a loop. Note that the vertices 3 and 4 are
joined by two edges, one from 3 to 4 and the other in the reverse direction.
We shall regard a directed graph as something which represents a network of
one-way streets, each vertex representing a junction and each edge representing
a one-way street from one junction to another. We may only travel along these
streets in the direction given by the arrowhead. A two-way street is represented
by two edges between the same two vertices but with opposite directions. In the
directed graph of the relation R above there is just one two-way street between
the junctions 3 and 4. Also in this graph we may move or travel down a single
one-way street from the junction 1 to the junction 4. However we cannot directly
move from 4 to 1 since there is no edge with arrow pointing from 4 to 1. We
may also move from 2 to 2 along the loop starting at 2 and ending at 2.
5.16 The Relation R
2
Let R be a relation on a set A. Then we may form the composition of R : A A
with R : A A. This denes the relation R
o
9
R : A A. The relation R
o
9
R is
usually denoted by R
2
. Recall that (in this case):
(x, z) R
2
if and only if there exists an object y (belonging to A)
such that (x, y) R and (y, z) R.
In terms of the directed graph of R this means that there exist two edges as
shown in the diagram:
In other words, (x, z) R
2
if and only if we can travel from the junction x to
the junction z along two one-way streets in succession via a single intermediate
junction y.
5.17 Worked Example
Let A = 0, 1, 2, 3, 4, 5, 6 and let the relation R : A A be given by:
R = (0, 1), (0, 4), (0, 5), (1, 2), (1, 4), (2, 0), (2, 2), (2, 5),
(3, 1), (3, 4), (4, 3), (6, 0), (6, 3).
We have already considered this relation and drawn its directed graph. We may
construct the relation R
2
by observing that:
93
Since (0, 1) R and (1, 2) S, (0, 2) R
2
;
Since (0, 1) R and (1, 4) S, (0, 4) R
2
;
Since (0, 4) R and (4, 3) S, (0, 3) R
2
;
Since (1, 2) R and (2, 0) S, (1, 0) R
2
;
Since (1, 2) R and (2, 2) S, (1, 2) R
2
;
Since (1, 2) R and (2, 5) S, (1, 5) R
2
;
Since (1, 4) R and (4, 3) S, (1, 3) R
2
;
Since (2, 0) R and (0, 1) S, (2, 1) R
2
;
Since (2, 0) R and (0, 4) S, (2, 4) R
2
;
Since (2, 0) R and (0, 5) S, (2, 5) R
2
;
Since (2, 2) R and (2, 0) S, (2, 0) R
2
;
Since (2, 2) R and (2, 2) S, (2, 2) R
2
;
Since (2, 2) R and (2, 5) S, (2, 5) R
2
;
Since (3, 1) R and (1, 2) S, (3, 2) R
2
;
Since (3, 1) R and (1, 4) S, (3, 4) R
2
;
Since (3, 4) R and (4, 3) S, (3, 3) R
2
;
Since (4, 3) R and (3, 1) S, (4, 1) R
2
;
Since (4, 3) R and (3, 4) S, (4, 4) R
2
;
Since (6, 0) R and (0, 1) S, (6, 1) R
2
;
Since (6, 0) R and (0, 4) S, (6, 4) R
2
;
Since (6, 0) R and (0, 5) S, (6, 5) R
2
;
Since (6, 3) R and (3, 1) S, (6, 1) R
2
;
Since (6, 3) R and (3, 4) S, (6, 4) R
2
.
Thus:
R
2
= (0, 2), (0, 3), (0, 4), (1, 0), (1, 2), (1, 3), (1, 5), (2, 0), (2, 1), (2, 2), (2, 4),
(2, 5), (3, 2), (3, 3), (3, 4), (4, 1), (4, 4), (6, 1), (6, 4), (6, 5).
In terms of the graph of R we may note that (0, 3) R
2
because we may travel
from 0 to 3 along two edges via 4:
Similarly the ordered pair (4, 4) belongs to R
2
because we may travel from 4 to
4 along two edges via 3: The pair (1, 2) belongs to R
2
because we can
travel from 1 to 2 along two edges in succession; namely along the edge from 1
to 2 and then along the loop from 2 to 2:
Similarly the pair (2, 2) belongs to R
2
since we may travel from 2 to 2 by moving
twice round the loop . The fact that (6, 4) R
2
may be explained in
94
two dierent ways. We may travel form 6 to 4 via 0 using the edges:
or via 3 using the edges: .
5.18 The Relation R
3
Let R : A A be a relation on the set A. Then, since composition of relations
is associative, R
2
o
9
R = R
o
9
R
2
. We will denote the relation R
2
o
9
R by R
3
. Thus:
(w, z) R
3
if and only if there exist objects x, y such that the pairs
(w, x), (x, y) and (y, z) belong to R.
It follows that (x, z) R
3
if and only if in the directed graph of R there three
edges as shown in the diagram:
In other words (w, z) R
3
if and only if we can travel along three successive
edges from x to z.
5.19 Worked Example
Let A = 0, 1, 2, 3, 4, 5, 6 and let R : A A be the relation as dened above;
viz.:
R = (0, 1), (0, 4), (0, 5), (1, 2), (1, 4), (2, 0), (2, 2), (2, 5),
(3, 1), (3, 4), (4, 3), (6, 0), (6, 3).
Then:
R
2
= (0, 2), (0, 3), (0, 4), (1, 0), (1, 2), (1, 3), (1, 5), (2, 0), (2, 1), (2, 2), (2, 4),
(2, 5), (3, 2), (3, 3), (3, 4), (4, 1), (4, 4), (6, 1), (6, 4), (6, 5).
It follows that, by a mental calculation:
R
3
= R
o
9
R
2
= (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 0), (1, 1), (1, 2), (1, 4),
(1, 5), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 0), (3, 1), (3, 2),
(3, 3), (3, 4), (3, 5), (4, 2), (4, 3), (4, 4), (6, 2), (6, 3), (6, 4).
The relation R
3
may also be determined from the directed graph of R. (w, z)
R
3
if and only if we can travel from w to z along three successive edges. For
example (2, 4) R
3
because we can travel from 2 to 4 via the vertices 0 and 1
as shown in the diagram:
95
Also (6, 3) R
3
as shown in the diagram:
The diagram:
shows that (3, 1) R
3
. To see that (1, 5) R
3
, note that we may travel from
1 to 5 in three moves, namely a move from 1 to 2 followed by a move round
the loop attached to the vertex 2 and nally a move from 2 to 5:
(1, 2) R
3
because we may travel from 1 to 2 along three successive edges;
namely along the edge from 1 to 2 followed by journey which goes twice round
the loop attached to the vertex 2. Similarly, by considering the journey which
goes three times round the loop attached to the vertex 2, (2, 2) R
3
.
5.20 The Relations R
n
for a natural number n
Given the relation R : A A on a set A, we may construct in succession the
relations R
2
, R
3
, R
4
, etc. by using the iteration:
R
n+1
= R
o
9
R
n
.
for all natural numbers n 1. We have already done this for the cases n = 1
and n = 2. By convention, we write R
0
= id A. Then the above iteration also
holds for n = 0 and hence is valid for all natural numbers n. Since the operation
o
9
is associative, we may prove, by induction that, for all natural numbers n:
R
n+1
= R
n
o
9
R.
For any natural number n, let P(n) be the statement:
R
n+1
= R
n
o
9
R.
The statement P(0) is clearly true. Assume that P(n) is true for the natural
number n. Then:
R
n+1
= R
n
o
9
R.
96
Hence:
R
n+2
= R
o
9
R
n+1
= R
o
9
(R
n
o
9
R)
= (R
o
9
R
n
)
o
9
R
= R
n+1
o
9
R.
Thus P(n + 1) is true. Therefore, by induction P(n) is true for all natural
numbers n. More generally we may show that for any natural numbers m and
n:
R
m
o
9
R
n
= R
m+n
= R
n
o
9
R
m
.
In particular:
R
4
= R
o
9
R
3
= R
2
o
9
R
2
.
It follows that (v, z) R
4
if and only if we can travel from v to z in four moves
in the directed graph of R; thus:
For example, if R is the relation on A = 0, 1, 2, 3, 4, 5, 6 with directed graph:
then from the following extract:
we see that (6, 3) R
4
.
To construct R
n
for large values of n, we do not need to evaluate all smaller
powers of R. For instance we may determine R
5
from R
2
and R
3
; thus
R
5
= R
2
o
9
R
3
. Then, for example, R
10
= R
5
o
9
R
5
and R
15
= R
5
o
9
R
10
.
We may consider negative powers of a relation R, by dening, for every
positive integer n, R
n
= (R

)
n
. Then, in particular, R
1
= R

. One word of
warning; the rule:
R
m+n
= R
m
o
9
R
n
is NOT valid for all integers m, n. For instance:
R
1
o
9
R
1
,= R
0
.
97
For example, consider the relation R : A A as dened above; viz.:
R = (0, 1), (0, 4), (0, 5), (1, 2), (1, 4), (2, 0), (2, 2), (2, 5),
(3, 1), (3, 4), (4, 3), (6, 0), (6, 3),
where A = 0, 1, 2, 3, 4, 5, 6. Then:
R
1
= R

= (0, 2), (0, 6), (1, 0), (1, 3), (2, 1), (2, 2), (3, 4), (3, 6),
(4, 0), (4, 1), (4, 3), (5, 0), (5, 2).
Hence:
R
o
9
R
1
= (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1),
(2, 2), (2, 6), (3, 0), (3, 1), (3, 3), (4, 4), (6, 2), (6, 4), (6, 6).
Thus R
o
9
R
1
,= id A; i.e. R
1
o
9
R
1
,= R
0
.
5.21 Non-Mathematical Example
Let Person be the set of all people (living or dead), and let parent-of : Person
Person be the set of all ordered pairs (x, y), where x and y are people and x
is a parent of y. Then we may construct further relations on the set Person,
by forming all positive powers of parent-of. In particular the relation parent-of
2
consists of all ordered pairs (x, z), where x and z are people and x is a grandpar-
ent of z. For (x, z) parent-of
2
if and only if there exists an object y in Person
such that (x, y and (y, z) belong to parent-of. Thus x is a parent of y and y is
a parent of z. Therefore x is a grandparent of z. Similarly (w, z) parent-of
3
if and only if w and z are people and w is a great grandparent of z. Thus we
may write:
parent-of
2
= grandparent-of,
and:
parent-of
3
= great-grandparent-of,
and so on.
98
5.22 Properties of Relations
A relation R on a set A is said to be:
(i) reexive if:
x : A xRx;
(ii) symmetric if:
x, y : A xRy = yRx;
(iii) transitive if:
x, y, z : A xRy yRz = xRz.
A relation R on A fails to be reexive, if there exists an element x A such
that (x, x) , R. For:
x : A xRx x : A xRx
x : A (x, x) A
x : A (x, x) , R.
Similarly:
x, y : A xRy = yRx x, y : A (xRy = yRx)
x, y : A ((x, y) R (y, x) R)
x, y : A (x, y) R (y, x) , R.
Thus R is not symmetric if there exist elements x, y of A such that (x, y) belongs
to R but not (y, x). By negating this statement, we observe that R is symmetric
if there do not exist elements x, y of A such that (x, y) R, but (y, x) , R. A
similar argument on the denition of transitivity, yields the statement: R is not
transitive if there exist elements x, y, z of A such that (x, y) and (y, z) belong
to R, but not (x, z). Thus R is transitive if there do not exist elements x, y, z
of A such that (x, y) and (y, z) belong to R, but not (x, z).
Consider the relation R on A = 1, 2, 3, 4, 5, 6 given by:
R = (1, 1), (1, 2), (2, 1), (2, 2), (2, 5), (3, 3),
(4, 2), (4, 4), (5, 2), (5, 5), ,
This relation is not reexive, since there exists the element 6 of A such that
(6, 6) , R. The relation is not symmetric, since there exist the elements 2, 4 of
A such that (4, 2) R, but not (2, 4). Again the relation is not transitive, since
there exist the elements 1, 2, 5 of A such that (1, 2) and (2, 5) belong to R, but
not (1, 5).
Example. Given a relation R on a set A, R may be reexive or it may not
be reexive. Thus relative to the condition of being reexive, there are two
possibilities. Similarly there are two possibilities regarding the conditions of
symmetry and transitivity. Then, with regard to all three conditions, there are
2
3
= 8 dierent cases. Let us construct an example for each of these cases with
A = 1, 2, 3.
For the relation R to be reexive we need the pairs (1, 1), (2, 2), (3, 3) to be
in R. With just these pairs in R, the relation is also symmetric and transitive.
99
Suppose that we require R to be reexive and transitive, but not symmetric.
For the relation not to be symmetric there exists elements x, y of A such that
(x, y) R, but not (y, x). In particular x ,= y. Let us suppose that (1, 2) R,
but not (2, 1). Thus the relation:
R = (1, 1), (1, 2), (2, 2), (3, 3)
is reexive, but not symmetric. It is also transitive, since there do not exist
elements x, y, z of A such that (x, y) and (y, z) belong to R, but not (x, z).
Suppose that R is reexive and symmetric, but not transitive. Then R
contains the pairs (1, 1), (2, 2), (3, 3). For R not to be transitive we require
elements x, y, z of A such that (x, y) and (y, z) belong to R, but not (x, z). We
may suppose, for instance, that (1, 2) and (2, 3) belong to R, but not (1, 3).
However, for R to be symmetric, the pairs (2, 1) and (3, 2) must belong to R.
Thus:
(1, 1), (1, 2), (2, 1), (2, 2), (2, 3), (3, 2) R.
It is easy to see that the relation (1, 1), (1, 2), (2, 1), (2, 2), (2, 3), (3, 2) is
reexive and symmetric, but not transitive. Therefore we may choose:
R = (1, 1), (1, 2), (2, 1), (2, 2), (2, 3), (3, 2).
Next suppose that R is reexive, but not symmetric nor transitive. Then as
above, since R is reexive, but not transitive:
(1, 1), (1, 2), (2, 2), (2, 3), (3, 3) R.
It suces to take:
R = (1, 1), (1, 2), (2, 2), (2, 3), (3, 3),
since this relation cannot also be symmetric.
For R not to be reexive there exists an element x of A such that (x, x) , R.
Simple arguments as above lead to the following examples:
R = (1, 1) is symmetric and transitive, but not reexive.
R = (1, 2), (2, 1) is symmetric, but not reexive nor transitive.
R = (1, 2) is transitive, but not reexive nor symmetric.
R = (1, 2), (2, 3) is not reexive nor symmetric nor transitive.
Given a relation R on a set A, we may ascertain by just looking at the
directed graph of R whether the relation is reexive or symmetric. For instance,
if A = 1, 2, 3, 4, 5 and the relation R : A A is given by:
R = (1, 1), (1, 2), (1, 3), (2, 2), (3, 2), (3, 3), (3, 5), (4, 4)
(4, 5), (5, 1), (5, 3), (5, 5),
then the directed graph of R is:
100
In this case R is reexive, since a loop is attached to each vertex. For a relation
to be symmetric there cannot be a one-way street between two junctions in its
graph. In this case R cannot be symmetric, since its graph contains a one-way
street joining the junctions 1 and 2. In other words the pair (1, 2) belongs to R
but not the pair (2, 1).
Consider the relation R : A A, where A = 1, 2, 3, 4, 5 and:
R = (1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (3, 4), (4, 1)
(4, 2), (5, 4), (5, 5).
Its directed graph is:
Since no loop is attached to the vertex 4, R is not reexive. It is not symmetric,
since its graph contains the one-way street from the junction 3 to the junction
4.
Consider the set:
A = Aldershot, Basingstoke, Maidenhead,
Reading, Oxford, Windsor.
and let R : A A be the relation on A with directed graph given by:
101
Then R is not reexive, since there is no loop attached to the vertex Reading.
R is not symmetric since its graph contains a one-way street from Reading
to Basingstoke. In the graph one cannot travel directly from Basingstoke to
Reading. Note that it takes a journey along at least two streets to travel from
Basingstoke to Reading. For instance we may journey from Basingstoke to
Reading via Oxford. If on the other hand the graph of R is:
then R is symmetric; there is no one-way street. The relation is still not reexive,
since there is no loop attached to the vertex Oxford.
It is more dicult to determine whether a relation is transitive by just look-
ing at its graph. Suppose that R : A A is a relation on a set A. Then in terms
of its graph R is transitive if and only if its graph has the following property:
Whenever a journey from one junction to another may be traveled
along two streets in succession it may be traveled directly along just
one street.
The previous relation is not transitive, since we can travel from Reading to
Oxford via Maidenhead, but we cannot go directly from Reading to Oxford.
In other words the pairs:
(Reading, Maidenhead), (Maidenhead, Oxford)
belong to R, but the pair (Reading, Oxford) does not. However the directed
graph:
represents a transitive relation on the set:
Sunday, Monday, Tuesday, Wednesday
Thursday, Friday, Saturday.
102
It is easy to see that in this graph any journey from one junction to another
along two streets in succession may also be performed directly along just one
street. Note that in the graph of a transitive relation, whenever there is a
two-way street, then a loop is attached to each of the two junctions joined by
the street. In the above graph there is a two-way street joining the junctions
Friday and Saturday. To each of these junctions is attached a loop. If we
were to remove the loop at the junction Saturday, we would obtain the graph:
of a relation which is not transitive. Although we may travel from Saturday to
Saturday along two streets in succession (via Friday) we can no longer make
the journey along just one street; i.e. a loop attached to the junction Saturday.
There are many other contexts in which we may consider relations with one
or more of the properties: reexive, symmetric and transitive. For instance,
let P be the set of all people and suppose that R is the relation on P which
relates two people with an account at the same bank. Thus, if x, y are two
people, then we write xRy if and only if x has an account at the same bank
as y. R need not be reexive, since not all people have bank accounts. It is
certainly symmetric. Again it need not be transitive, since some people have
bank accounts at two dierent banks. For example a person x may have a bank
account at Barclays Bank only, a person y may have accounts at both Barclays
Bank and Lloyds Bank, and a person z may have an account at Lloyds Bank
only. Then (x, y) R and (y, z) R, but (x, z) , R.
5.23 Partitions of a Set
Let A be a set. Then a set of non-empty subsets of A is called a partition of
A if each element of A belongs to exactly one of these subsets. For example, if
A = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, then:
0, 2, 4, 1, 3, 5, 6, 8, 9, 7
is a partition of A. On the other hand:
0, 2, 4, 1, 3, 5, 6, 8, 9, 3, 7
is not a partition of A, since, although each element of A belongs to one of these
subsets, the element 3 belongs to two of them; namely 1, 3 and 3, 7. Also:
0, 2, 4, 1, 3, 5, 6, 8, 9
103
is not a partition of A, since the element 7 does not belong to any of the subsets
listed. Note that a set of subsets of A is a partition of A if and only if their
union is the set A and the intersection of any two distinct subsets of the set is
empty; i.e. the subsets are disjoint. Thus a partition of A splits or partitions
A into disjoint parts. For example we may partition the set P of all pieces in a
chess set into the set W of all white pieces and the set B of all black pieces; i.e.
the set W, B is a partition of P. Similarly a deck of cards may be partitioned
into the 4 dierent suits; viz. clubs, diamonds, hearts and spades. Thus, if C
is the set of cards bearing clubs, D is the set of all cards bearing diamonds, H
is the set of all cards bearing hearts and S is the set of all cards bearing spades,
then C, D, H, S is a partition of set A of all cards in the deck.
5.24 Equivalence Relations
A relation R on a set A is said to be an equivalence relation on A if it is reexive,
symmetric and transitive. For example let A = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and
suppose that the relation R on A is given by:
R = (0, 0), (0, 2), (0, 4), (1, 1), (1, 3), (2, 0), (2, 4), (3, 1),
(3, 3), (4, 0), (4, 2), (4, 4), (5, 5), (5, 6), (5, 8), (5, 9),
(6, 5), (6, 6), (6, 8), (6, 9), (7, 7), (8, 5), (8, 6),
(8, 8), (8, 9), (9, 5), (9, 6), (9, 8), (9, 9).
It is easy to see that R is reexive and symmetric. Its graph is:
Note that a loop is attached to each vertex and all streets are two-way. By a
closer investigation it can be seen that R is also transitive. Observe from the
graph that the set A may be partitioned into 4 subsets:
0, 2, 4, 1, 3, 5, 6, 8, 9, 7.
Note that elements x and y of A belong to the same subset if and only if
(x, y) R. In other words x and y belong to the same subset if and only if
we can travel along a street from x to y. We may prove that this is a property
of all equivalence relations. The subsets in the partition are called equivalence
classes.
104
Let R be an equivalence relation on a set A. Let x A. Dene:
[x] = y : A [ (x, y) R.
Then for all elements x of A [x] is a subset of A. Since R is reexive, (x, x) R
for every element x of A. Thus x [x] for every x in A. Therefore, if P denotes
the set of all subsets of A of the form [x] for some x in A, every element of A
belongs to at least one of the subsets contained in P. We claim that distinct
subsets X and Y in P are disjoint; i.e. X Y = . Assume that X and Y
are distinct subsets of A in P and that z X Y . Suppose that X = [x]
and Y = [y] for some x, y A. Then, since z X = [x] and z Y = [y],
(x, z) R and (y, z) R. Since R is symmetric, (z, y) R. Hence, since R
is transitive, (x, y) R. Since R is symmetric, (y, x) R. If w X = [x],
then (x, w) R and hence, since R is transitive and (y, x) R, (y, w) R.
Thus w [y] = Y . Hence X Y . Since (x, y) R, a similar argument shows
that Y X. Therefore X = Y . This is a contradiction, since we assumed that
X and Y are distinct. It follows that distinct subsets of A in P are disjoint.
Therefore P is a partition of A. The subsets in P are called equivalence classes
of R.
Let P be a partition of A. Dene the relation R
P
on A so that, if x, y A,
then (x, y) R
P
if and only if x and y belong to the same subset of A in P.
It is easy to show that R
P
is an equivalence relation and that P is the set of
equivalence classes of R
P
. We may also prove that, if P is the set of equivalence
classes of an equivalence relation R on a set A, then R
P
= R. Therefore
equivalence relations on a set A may be regarded as partitions of the set A and
conversely. They represent dierent points of view of the same concept.
Partitions occur naturally in many situations in which objects are classied.
For example, the books in a library are classied by subject matter. They are
given an appropriate class number. Books belonging to the same class are given
the same class number. The set of books in the library is therefore partitioned
into subsets of books with the same class number. Two books are related if they
have the same class number. This relation is an equivalence relation.
5.25 Worked Example
Let A = a, b, c, d, e, f, g, h, where a, b, c, d, e, f, g, h are distinct objects. Let
R, S, T be the relations on A given by:
R = a a, b b, c c, c g, c h, d d,
e c, e e, e g, e h, f f, g c,
g g, g h, h c, h g, h h;
S = a a, a b, a d, a h, b a, b b,
b d, b h, c c, c e, c g, d a
d b, d d, d h, e c, e e, g c,
g g, h a, h b, h d, h h;
T = a b, a c, a d, a e.
Answer the following questions, and justify each negative answer:
105
(i) Is R reexive?
(ii) Is R symmetric?
(iii) Is R transitive?
(iv) Is R an equivalence relation?
(v) Is S reexive?
(vi) Is S symmetric?
(vii) Is S transitive?
(viii) Is S an equivalence relation?
(ix) Is T reexive?
(x) Is T symmetric?
(xi) Is T transitive?
(xii) Is T an equivalence relation?
Solution. [1] Yes.
[2] No. Since(e, c) R but (c, e) , R, R is not symmetric.
[3] Yes.
[4] No. R is not an equivalence relation since it is not symmetric.
[5] No. Since (f, f) , S, S is not reexive.
[6] Yes.
[7] No. Since (e, c) S and (c, g) S, but (e, g) , S, S is not transitive.
[8] No. S is not an equivalence relation since it is not reexive.
[9] No. Since (a, a) , T, T is not reexive.
[10] No. Since (a, b) T, but (b, a) , T, T is not symmetric.
[11] Yes.
[12] No. T is not an equivalence relation since it is not reexive.
Remark. It is easy to check when a relation is reexive and symmetric, but not
so easy to deal with transitivity. Note that a relation R on a set A is transitive
if and only if R
o
9
R R. For, if R is transitive and (x, z) R
o
9
R, then there
exists an object y in A such that (x, y) R and (y, z) R and hence (x, z) R.
Conversely, if R
o
9
R R and if (x, y) R and (y, z) R, then (x, z) R
o
9
R
and hence (x, z) R. Thus to verify that a relation is transitive, we must
compute R
o
9
R and check whether R
o
9
R is a subset of R. By a long and detailed
computation:
R
o
9
R = (a, a), (b, b), (c, c), (c, g), (c, h), (d, d),
(e, c), (e, e), (e, g), (e, h), (f, f), (g, c),
(g, g), (g, h), (h, c), (h, g), (h, h).
106
Thus R
o
9
R R and hence R is transitive. Similarly:
T
o
9
T = .
Therefore T
o
9
T T and hence T is transitive.
107
108
Chapter 6
FUNCTIONS
6.1 Total and Partial Functions
Let R : A B be a relation between sets A and B. In most cases each element
of A may be R-related to more than one element of B. For example, if A is
the set of all students in a University, B is the set of all subjects taught in the
University and R is the set of all ordered pairs (x, y) such that student x studies
the subject y, then each student may study more than one subject.
Now suppose that C is the set of all dates (such as 1 October 1969). Dene
the relation S : A C so that (x, y) S if and only if the student x has
the date of birth y. Then since every student has exactly one date of birth,
S : A C is a relation in which every element x of A is S-related to exactly
one element of C. We may denote the date of birth of the student x by S(x).
Then S consists of all ordered pairs of the form (x, S(x)), where x A. We say
that S is a total function from the set A to the set C.
Let D be the set of all Halls of Residence of the University and let T be the
set of all ordered pairs (x, y), where x is a student who is living in the Hall of
Residence y. In this case, since not all students live in a Hall of Residence, but,
if so, a student can only live in just one Hall of Residence, each element of A
is T-related to at most one element of D. We say that T is a partial function
from A into D. If we restrict T to those students living in a Hall of Residence,
then T becomes a total function; i.e. if E is the set of students living in Hall,
then E T may be regarded as a total function from E into D. In this case,
if x E we may denote the Hall in which x lives by T(x). If x A E, then
T(x) has no meaning. Note that E = domT.
Let A and B be sets and suppose that R : A B is a total function from
A into B. If x A then R(x) denotes the unique object in B to which x is
R-related. We call R(x) the R-image of x or the image of x under R or the
value of R at x. Note that domR = A, since every object of A is R-related to
exactly one element of B. The declaration R : A B is used to denote a total
function from A into B.
Now suppose that R : A B is a partial function from A to B. Let
E = domR. Then every element of E is R-related to exactly one element of B,
but every element of A not belonging to E is not R-related to any element of
B. Thus E is the set of all elements of A which are R-related to exactly one
109
element of B. If x E, then x is R-related to a unique element of B which
is denoted by R(x). The declaration R : A B is used to denote a partial
function. Clearly a total function is also a partial function. Indeed a total
function f : A B is a partial function f : A B for which domf = A.
Note also that a partial function is in particular a relation between two sets. If
the relation R : A B is a total function, then the declaration R : A B is
preferable to the declarations R : A B and R : A B, since a total function
is more than just a relation or partial function.
Example. Let A = 0, 1, 2, 3, 4, B = 5, 6, 7 and let:
f = 0 5, 1 7, 2 6, 3 5, 4 7.
Then f is a relation between the sets A and B. Moreover, since every element
of A is f-related to exactly one element of B, f is a total function from A to B,
and we may write f : A B. To be precise:
0 is f-related to 5;
1 is f-related to 7;
2 is f-related to 6;
3 is f-related to 5;
4 is f-related to 7,
and no element of A is f-related to any element of B other than the one given
in this list. Note that all the declarations:
f : A B f : A B f : A B
are valid, but the rst is the most informative. Note also that:
f(0) = 5; f(1) = 7; f(2) = 6; f(3) = 5; f(4) = 7.
Since f is a total function domf = A. In this case ran f = B.
Example. Let A = 0, 1, 2, 3, 4, B = 5, 6, 7 and let:
g = 1 7, 2 6, 4 7.
Then g is a relation between the sets A and B. Moreover, since every element
of A is g-related to at most one element of B, g is a partial function from A to
B, and we may write g : A B. To be precise:
0 is not g-related to any element of B;
1 is g-related to 7;
2 is g-related to 6;
3 is not g-related to any element of B;
4 is g-related to 7,
and no element of A is g-related to any element of B other than the one given
in this list. Note that the declarations:
g : A B g : A B
are both valid, but the rst is the most informative. The declaration f : A B
is invalid. Note that in this case we may write:
g(1) = 7; g(2) = 6; g(4) = 7.
The domain of g is 1, 2, 4 and the range of g is 6, 7.
110
Example. Let A = 0, 1, 2, 3, 4, B = 5, 6, 7 and let:
h = 0 5, 1 7, 2 6, 3 5, 4 7, 2 5.
Then h is a relation between the sets A and B. Moreover, since 2 is h-related
to two elements of B; namely 5 and 6, g is neither a total function nor a partial
function from A to B. To be precise:
0 is h-related to 5;
1 is h-related to 7;
2 is h-related to both 5 and 6;
3 is h-related to 5;
4 is h-related to 7.
Note that only the declaration h : A B is valid. The declarations h : A B
and h : A B are both invalid.
Since (partial and total) functions are in particular relations, everything
that applies to relations also applies to functions. Let f : A B be a partial
function from the set A to the set B. Then f is a set of ordered pairs (x, y),
with x A and y B. If (x, y) f, then x domf and, since f is a partial
function, y is the only element of B to which x is f-related. Indeed we may
write y = f(x). Thus f consists of all ordered pairs (x, f(x)), where x domf
and no others. From the above examples we may write:
f = (0, f(0)), (1, f(1)), (2, f(2)), (3, f(3)), (4, f(4));
g = (1, g(1)), (2, g(2)), (4, g(4)).
Since h is not a partial function, we cannot express h in the same way.
6.2 Injective Functions
Certain properties of function arise when we investigate conditions for a given
function to have an inverse; i.e. when is the inverse relation of a function also
a function. Let f : A B be a partial function. Under what condition is the
inverse relation f

: B A a partial function? Suppose that f

: B A is
indeed a partial function. Then every element of B is R

-related to at most
one element of A. We claim that no two distinct elements of A are f-related to
the same element of B. For assume that the distinct elements x and y of A are
f-related to the same element z of B. Then (x, z) f and (y, z) f. Hence
(z, x) and (z, y) both belong to f

. Thus z is f

-related to at least two distinct


elements x and y of A; contradiction. Therefore no two distinct elements of A
are f-related to the same element of B.
Denition. Let A and B be sets. A partial function f : A B is said to be
injective if no two distinct elements of A are f-related to the same element of
B; i.e. have the same f-image.
Thus, if f : A B is a partial function such that the inverse relation
f

: B A is also a partial function, then f is injective. The converse holds;


i.e. if f : A B is injective, then the inverse relation f

: B A is a partial
111
function. It is easy to see that f : A B is injective if and only if whenever
x, y A such that f(x) = f(y), then x = y. For:
x, y : A f(x) = f(y) = x = y x, y : A f(x) = f(y) x = y
x, y : A f(x) = f(y) x ,= y
x, y : A (f(x) = f(y) x ,= y)
(x, y : A f(x) = f(y) x ,= y).
The last line in this argument asserts that no two distinct elements of A have
the same f-image; i.e. that f is injective. Note also that f is injective if and
only if, whenever x and y are distinct elements of domf, f(x) and f(y) are
distinct elements of B. In the study of relations the condition described in the
denition of injectivity may be regarded as complimentary to the condition for
a partial function.
Example. Let A = 0, 1, 2, 3, B = 4, 5, 6, 7, 8, 9 and let:
g = (0, 5), (2, 8), (3, 4).
Then g : A B is a relation and:
0 is g-related to 5;
1 is not g-related to any element of B;
2 is g-related to 8;
3 is g-related to 4,
and no element of A is g-related to any element of B other than the one given
in this list. Thus g is a partial function. Clearly no two elements of A are
g-related to the same element of B. Therefore g is injective. Note that the
inverse relation g

: B A is given by:
g

= (4, 3), (5, 0), (8, 2).


Clearly g

is also a partial function. Note that g

is also injective. This is


because g is the inverse relation of g

; i.e. the inverse relation, g, of the partial


function g

is a partial function.
Example. Let A = 0, 1, 2, 3, B = 4, 5, 6, 7, 8, 9 and let:
h = (0, 5), (2, 8), (3, 5).
Then h : A B is a relation and:
0 is h-related to 5;
1 is not h-related to any element of B;
2 is h-related to 8;
3 is h-related to 5,
and no element of A is g-related to any element of B other than the one given
in this list. Thus h is a partial function. In this case the elements 0 and 3 of A
are h-related to the same element, 5, of B. Therefore h is not injective. Note
that the inverse relation h

: B A is given by:
h

= (5, 0), (5, 3), (8, 2).


Clearly h

is not a partial function. Note that injectivity has no meaning for


general relations; it only applies to partial functions.
112
Example. Let A = 0, 1, 2, 3, B = 4, 5, 6, 7, 8, 9 and let:
k = (0, 5), (0, 8), (3, 4).
Then k : A B is a relation and:
0 is k-related to both 5 and 8;
1 is not k-related to any element of B;
2 is not k-related to any element of B;
3 is g-related to 4.
Since 0 is related to more than one element of B, k is not a partial function.
Note that the inverse relation k

: B A is given by:
k

= (4, 3), (5, 0), (8, 0).


Clearly k

is a partial function. Note that k

is not injective, because the


inverse relation, k, of the partial function k

is not a partial function.


An injective partial function from a set A to a set B is called a partial
injection from A to B. The declaration f : A B is used to indicate that f
is a partial injection from A to B. Note that, if the declaration f : A B is
valid, then so are the declarations:
f : A B; f : A B.
However f : A B is the most informative of the three declarations. In the
above three examples, the declarations:
g : A B, g : A B, g : A B;
h : A B, h : A B;
k : A B
are valid, but not the declarations:
h : A B; k : A B; k : A B.
Let f : A B be a partial injection. If y ran f, then, since f is injective,
there exists one and only one element x domf such that (x, y) f; i.e.
f(x) = y. Indeed, since (y, x) f

and f

is a partial function, x = f

(y).
Thus, if y ran f, then f

(y) is the (unique) element x of domf such that


f(x) = y.
Example. Let A = 1, 2, 3, 4, 5 and let B = p, q, r, s, where p, q, r, s are
distinct objects. Let:
f = 2 r, 4 p, 5 s.
Then f : A B is a partial injection and f

: B A is a partial function.
Also:
domf = 2, 4, 5; ran f = r, p, s.
Moreover:
f

= r 2, p 4, s 5.
Hence:
f

(r) = 2; f

(p) = 4; f

(s) = 5.
Indeed:
113
f

(r) = 2 is the (unique) element x of domf such that f(x) = r;


f

(p) = 4 is the (unique) element x of domf such that f(x) = p;


f

(s) = 5 is the (unique) element x of domf such that f(x) = s.


Because a total function is also a partial function, the same denition of
injectivity applies to total functions. An injective total function f from a set
A to a set B is called a total injection from A to B and is declared by the
expression f : A B. If f is a total injection from A to B, then all the
following declarations are valid:
f : A B (f is a total injection from A to B).
f : A B (f is a partial injection from A to B).
f : A B (f is a total function from A to B).
f : A B ( f is a partial function from A to B).
f : A B (f is a relation between A and B).
Example. Let A = 0, 1, 2, 3, B = 4, 5, 6, 7, 8, 9 and let:
e = 0 8, 1 5, 2 6, 3 9.
Then:
0 is e-related to 8;
1 is e-related to 5;
2 is e-related to 6;
3 is e-related to 9,
and no element of A is e-related to any element of B other than those given
in the list. Thus each element of A is e-related to exactly one element of B.
Therefore e is a total function from A to B. Moreover, from the above list it
is clear that no two distinct elements of A are e-related to the same element of
B. Hence f is a total injection from A to B. It follows that all the following
declarations are valid:
e : A B;
e : A B;
e : A B;
e : A B;
e : A B.
6.3 Surjective Functions
Recall that injectivity may be regarded as complimentary to the condition for
a relation to be a partial function and that the condition for a partial function
f : A B to be a total function is that domf = A. We may regard the
condition ran f = B to be complimentary to the condition domf = A. A
partial or total function f from a set A to a set B is said to be surjective if
ran f = B. This is equivalent to the:
Denition. A partial or total function from the set A to the set B is said to be
surjective if every element of B is the f-image of at least one element of A.
114
A surjective partial function is called a partial surjection and a surjective
total function is called a total surjection. We declare a partial surjection f from
a set A to a set B by the expression f : A B and a total surjection f from
A to B by the expression f : A B.
Example. Let A = m, n, p, q, r, s, t, u, v,where m, n, p, q, r, s, t, u, v are distinct
objects, let B = 1, 2, 3, 4 and let:
g = (n, 3), (p, 1), (q, 3), (s, 2), (t, 4), (u, 3), (v, 2).
Then g : A B is a partial function and:
1 is the g-image of p;
2 is the g-image of s and of v;
3 is the g-image of n, of q and of u;
4 is the g-image of t.
Therefore each element of B is the g-image of at least one element of A. There-
fore g is surjective. It follows that the following declarations are valid:
g : A B (g is a partial surjection from A to B);
g : A B (g is a partial function from A to B);
g : A B (g is a relation between A and B).
Example. Let A = m, n, p, q, r, s, t, u, v,where m, n, p, q, r, s, t, u, v are distinct
objects, let B = 1, 2, 3, 4 and let:
h = (m, 1), (n, 2), (q, 4), (s, 1), (t, 4).
Then h : A B is a partial function and:
1 is the h-image of m and of s;
2 is the h-image of n;
3 is not the h-image of any element of A;
4 is the h-image of q and of t.
Therefore not all elements of B are the h-image of an element of A. Thus h is
NOT surjective. The declaration h : A B is NOT valid. However the two
declarations h : A B and h : A B are valid.
Putting C = 1, 2, 4 and regarding h as a partial function from A to C,
every element of C is the h-image of at least one element of A. Thus h : A C
is a partial surjection. We may always restrict a partial (or total) function in
this way to turn it into a partial (or total) surjection.
Example. Let A = m, n, p, q, r, s, t, u, v,where m, n, p, q, r, s, t, u, v are distinct
objects, let B = 1, 2, 3, 4 and let:
k = (m, 3), (n, 1), (n, 4), (q, 2), (r, 3), (u, 4).
Then k : A B is a relation and:
m is k-related to 3;
m is k-related to both 1 and 4;
q is k-related to 2;
r is k-related to 3:
u is k-related to 4.
115
Although ran k = B, we cannot say that k is surjective. For k is not even a
partial function. Note that m is related to more than one element of B. The
only valid declaration in this case is k : A B.
Example. Let A = m, n, p, q, r, s, t, u, v,where m, n, p, q, r, s, t, u, v are distinct
objects, let B = 1, 2, 3, 4 and let:
e = (m, 3), (n, 2), (p, 3), (q, 1), (r, 2), (s, 4), (t, 3), (u, 1), (v, 3).
Then e is a total function from A to B. Moreover:
1 is the e-image of q and of u;
2 is the e-image of n and of r;
3 is the e-image of each of the elements m, p, t, v;
4 is the e-image of s.
Each element of B is the e-image of at least one element of A. Hence f is a
total surjection from A to B. It follows that all the following declarations are
valid:
e : A B (e is a total surjection from A to B);
e : A B (e is a partial surjection from A to B);
e : A B (e is a total function from A to B);
e : A B (e is a partial function from A to B);
e : A B (e is a relation between A and B).
6.4 Bijective Functions
Let f : A B be a partial function from the set A to the set B. Recall that,
the inverse relation f

: B A is a partial function if and only if f is injective.


Moreover, if f is injective then so is the partial function f

: B A.
Now suppose that f : A B is a total function. We now investigate under
what conditions the inverse relation f

: B A is a total function. For f

to
be a total function, it must be in particular a partial function. Thus f must be
a partial injection. This means that f is a total injection. Also for f

to be
a total function, domf

= B. But domf

= ran f. Thus ran f = B; i.e. f


is surjective. Thus for f

to be a total function, f must be both injective and


surjective.
Suppose that the total function f : A B is both injective and surjective.
Since f is surjective, every element of B is the f-image of at least one element
of A. Since f is injective, no two distinct elements of A have the same f-image;
i.e. every element of B is the f-image of at most one element of A. Thus every
element of B is the f-image of exactly one element of A. Conversely, if every
element of B is the f-image of exactly one element of A, then f is both injective
and surjective.
Denition. Let f : A B be a total function from the set A to the set B. f is
said to be bijective if every element of B is the f-image of exactly one element
of A.
Thus, if f : A B is a total function and, if the inverse relation f

B A
is a total function, then f is bijective. The converse holds; i.e. if f : A B is a
116
bijective total function, then the inverse relation f

B A is a total function.
Since f is injective, f

: B A is a partial function. Since f is surjective:


domf

= ran f = B.
Thus f

is a total function. Moreover f

is bijective. For we have already


seen that, since f is a partial injection, f

is a partial injection. Thus f

is
injective. Also, since:
ran f

= domf = A,
f

is surjective. Since f

is both injective and surjective, it is bijective. f

is
called the inverse function of f and is usually denoted by f
1
.
A bijective total function from a set A to a set B is also called a bijection
from A to B. The declaration f : A B is used to indicate that f is a bijection
from A to B.
Example. Let A = p, q, r, s, t, u, where p, q, r, s, t, u are distinct objects, let
B = 1, 2, 3, 4, 5, 6 and let:
g = (p, 3), (q, 4), (r, 1), (s, 5), (t, 2), (u, 6).
Clearly g is a total function from A to B. Moreover:
1 is the g-image of r;
2 is the g-image of t;
3 is the g-image of p;
4 is the g-image of q;
5 is the g-image of s;
6 is the g-image of u,
and no element of B is the g-image of any element of A other than the ones
given in the list. It follows that g is bijective. In this case all the following
declarations are valid:
g : A B, g : A B, g : A B, g : A B,
g : A B, g : A B, g : A B, g : A B.
Now:
g
1
= g

= (1, r), (2, t), (3, p), (4, q), (5, s), (6, u).
Note that the bijection g pairs o elements of A with elements of B in a one-
to-one fashion. Each element A of pairs o with just one element of B and
each element of B pairs o with just one element of A. Thus:
p pairs with just 3 = g(p);
q pairs with just 4 = g(q);
r pairs with just 1 = g(r);
s pairs with just 5 = g(s);
t pairs with just 2 = g(t);
u pairs with just 6 = g(u),
and:
117
1 pairs with just r = g

(1);
2 pairs with just t = g

(2);
3 pairs with just p = g

(3);
4 pairs with just q = g

(4);
5 pairs with just s = g

(5);
6 pairs with just u = g

(6).
This feature is common to all bijections. If f : A B is a bijection from
the set A to the set B, then each element x A is paired with f(x) and each
element y B is paired with f

(y). Thus bijections are just one-to-one pairings


of one set with another. Note that the two sets must have the same number of
elements.
6.5 Worked Example
Let A = p, q, r, s, t and B = 1, 2, 3, 4, 5, 6, 7, 8, where p, q, r, s, t are distinct
objects. Answer the following questions, and justify each negative answer:
(i) Is (1, s), (2, q), (3, p), (4, s), (5, t), (6, p), (7, r), (8, t) a total surjection
from B to A?
(ii) Is p 2, r 4, s 1, t 4 a partial injection from A to B?
(iii) Is (1, p), (2, r), (3, p), (5, s), (6, p), (7, t) a partial surjection from B to
A?
(iv) Is 5 p, 3 s, 7 t, 8 q a partial injection from B to A?
(v) Is (3, p), (4, r), (3, q), (5, t) a partial function from B to A?
(vi) Is p 4, s 3, r 6, t 2 a total injection from A to B?
Solution. (i) Yes.
(ii) No. If R = p 2, r 4, s 1, t 4, then two distinct elements, r, t,
of A are R-related to the same element of B, and hence R is not injective.
(iii) No. If R = (1, p), (2, r), (3, p), (5, s), (6, p), (7, t), then the element q of
A is not the R-image of any element of B, and so R is not surjective.
(iv) Yes.
(v) No. If R = (3, p), (4, r), (3, q), (5, t), then the element 3 of B is R-
related to two elements of A, and hence R is not a partial function from
B to A.
(vi) No. If R = p 4, s 3, r 6, t 2, then the element q of A is not
R-related to any element of B, and so R is not a total function from A to
B. Therefore R cannot be an injective total function from A to B; i.e. a
total injection from A to B.
118
6.6 Functions as Operators or Procedures
A total function f : A B from a set A to a set B may be regarded as
an operator or procedure. If we input an element x of A, the procedure,
f,outputs the element f(x) of B. The operator need not be some random
process, but one which is regulated by some precise rule or rules. It may simply
be the rule which species the precise element which is output for each element
of A. Thus for example we may specify the total function f : A B, where
A = 0, 1, 2, 3, 4, 5 and B = p, q, r, s, t, by the rule:
f(0) = r, f(1) = t, f(2) = p, f(3) = p, f(4) = q, f(5) = r.
More regulated rules might involve a mathematical formula such as:
f(x) = x
2
3x + 1,
or a computer program.
A partial function f : A B may be regarded in the same way, but in
this case we must also specify a particular subset of A; namely the set domf.
We must input only those elements x of A which belong to domf to obtain an
output f(x). If x A and y B, then the statement x is f-related to y is
equivalent to the statement x domf and y = f(x).
6.7 Relational Images of Functions
Let f : A B be a function from the set A to the set B. Let E be a subset of
A and F be a subset of B. Then f([E[) is a subset of B and f

([F[) is a subset
of A. An element y of B belongs to f([E[) if and only if y is the f-image of at
least one element of E. Thus:
f([E[) = y : B [ x : A y = f(x) x E
= f(x) x : A [ x E.
An element x of A belongs to f

([F[) if and only if x is f-related to at least one


element; namely f(x); of F; i.e. f(x) F. Thus:
f

([F[) = x : A [ f(x) F.
Example. Let A = 0, 1, 2, 3, 4, 5, 6, 7, 8 and B = p, q, r, s, t, u, where p, q, r, s,
t, u are distinct objects. Let f : A B be the total function such that:
f(0) = p, f(1) = r, f(2) = t, f(3) = p, f(4) = r,
f(5) = s, f(6) = t, f(7) = r, f(8) = u.
Let E = 0, 2, 3, 4, 5, 7 and F = r, s, u. Then:
f([E[) = f(0), f(2), f(3), f(4), f(5), f(7)
= p, t, p, r, s, r
= p, r, s, t.
Since f(1) = r, f(4) = r, f(5) = s, f(7) = r, f(8) = u all belong to F, but
f(0) = p, f(2) = t, f(3) = p, f(6) = t do not:
f

([F[) = 1, 4, 5, 7, 8.
119
Now suppose that f : A B be a partial function form the set A to the set
B. Let E be a subset of A and let F be a subset of B. Then again f([E[) is a
subset of B and f

([F[) is a subset of A. An element y of B belongs to f([E[) if


and only if at least one element of E is f-related to y. Since any element of A
which is f-related to an element of B must belong to domf, an element y of B
belongs to f([E[) if and only if at least one element of E domf is f-related to
y. Thus:
f([E[) = y : B [ x : A y = f(x) x E domf
= f(x) x : A [ x E domf.
An element x of A belongs to f

([F[) if and only if x is f-related to at least one


element; namely f(x); of F; i.e. f(x) F, in which case x domf. Thus:
f

([F[) = x : A [ x domf f(x) F.


Example. Let A = m, n, p, q, r, s, t, u, v, w, where m, n, p, q, r, s, t, u, v, w are
distinct objects and let B = 0, 1, 2, 3, 4, 5. Let f : A B be the partial
function such that domf = m, p, q, s, t, v and:
f(m) = 2, f(p) = 3, f(q) = 2, f(s) = 0, f(t) = 3, f(v) = 4.
Let E = m, n, q, s, u and F = 1, 2, 4, 5. Then:
E domf = m, q, s
and so:
f([E[) = f(m), f(q), f(s)
= 2, 2, 0
= 0, 2.
Now f(m) = 2, f(q) = 2, f(v) = 4 belong to F, but f(p) = 3, f(s) = 0, f(t) =
3 do not belong to F. Therefore:
f

([F[) = m, q, v.
6.8 Worked Example
Let S be the set of all students in the University of Wokingham and let H be
the set of all Halls of Residence in that University. George, Mary and Sally are
three students who belong to S. The following arrangements are at present in
existence at the University:
Some of the Halls are self-catering; i.e the students in these Halls
provide their own meals;
Every student lives in a Hall of Residence;
The students in each Hall of Residence have elected, from among
their number, a representative to serve on the Council of the Uni-
versity and a representative to serve on the Senate of the University;
Each student has just taken an examination in Mathematics, an ex-
amination in Physics and an examination in Chemistry, and has been
120
awarded a mark belonging to the set M = x : N [ 0 x 100;
A student passes an examination if and only if the mark awarded in
that examination is at least 40;
A student receives a prize if he or she obtains either a mark of at
least 80 in the Mathematics examination or a mark of at least 70 in
both the Physics examination and the Chemistry examination.
Give suitable denitions of a subset J of H, three subsets P, Q, R of M and
six functions f : S M, g : S M, h : S M, k : S H, d : H S and
e : H S, and then re-write the following statements about the University of
Wokingham in a form which contains no words or symbols other than:
George, Mary, Sally, f, g, h, k, d, e, =, ,=, , ,
J, P, Q, R, S, , ([, [), (, ), ran , , , .
(i) George and Mary do not live in the same Hall.
(ii) Mary lives in a Hall which is represented by Sally on the Council.
(iii) The Senate representatives of all the Halls passed the examination in
Mathematics.
(iv) Marys examination performance qualies for a prize.
(v) No self-catering Hall is represented on the Council and Senate by the
same student.
(vi) Every student who does not represent a Hall on the Council or Senate
passed the Chemistry examination.
Solution. Let us dene J to be the set of all self-catering Halls in the University
of Wokingham. Then J is a subset of H. Let:
P = x : N [ 40 x 100;
Q = x : N [ 70 x 100;
R = x : N [ 80 x 100.
Then P, Q, R are subsets of M. Let us dene six total functions f : S M,
g : S M, h : S M, k : S H, d : H S, e : H S by specifying that
for each student x in the set S:
f(x) is the mark obtained by x in the Mathematics examination;
g(x) is the mark obtained by x in the Physics examination;
h(x) is the mark obtained by x in the Chemistry examination;
k(x) is the Hall of Residence in which x lives,
and that for each Hall y in the set H:
d(y) is the student who represents y on the Council;
e(y) is the student who represents y on the Senate.
We can now re-write the statements in the required way as follows:
(i) The Hall in which George lives is k(George) and the Hall in which Mary
lives is k(Mary). Therefore the statement says that k(George) ,= k(Mary).
121
(ii) The Hall in which Mary lives is k(Mary). Therefore the student who
represents that Hall on the Council is d(k(Mary)). Hence the statement
says that d(k(Mary)) = Sally.
(iii) Since e is a total function from H to S, its domain, dome, is H. Therefore
its range, ran e, is the set of all objects of the form e(x), where x H.
Thus the statement asserts that every student in the set ran e passed the
examination in Mathematics. If x is a student, then f(x) is his or her
mark in the Mathematics examination. Therefore the student x passed the
examination in Mathematics if and only if f(x) P. Hence the statement
every student in ran e passed the Mathematics examination is equivalent
to the statement the f-image of every element of ran e belongs to P; i.e.
the set of all f-images of elements of ran e is a subset of P. The set of all
f-images of elements of ran e is given by f([ ran e[). Therefore the required
statement is f([ ran e[) P.
(iv) There are two methods by which a student may qualify for a prize. The
rst method is to obtain a Mathematics mark of at least 80. Thus Mary
qualies for a prize by this method if and only if her Mathematics mark,
f(Mary), belongs to the set R; i.e. f(Mary) R. Now f(Mary) R if
and only if Mary belongs to the set f

([R[). Thus Mary qualies for a


prize by the rst method if and only if she belongs to the set f

([R[).
The second method is to obtain Physics mark of at least at least 70 and
a Chemistry mark of at least 70. Thus Mary qualies for a prize by this
method if and only if g(Mary) Q and h(Mary) Q; i.e. if and only if
Mary belongs to the sets g

([Q[) and h

([Q[). Thus Mary qualies for a


prize by this method if and only if she belongs to the set g

([Q[) h

([Q[).
It follows that Mary qualies for a prize if she belongs to either the set
f

([R[) or the set g

([Q[) h

([Q[). Therefore the given statement may be


expressed in the form:
Mary f

([R[) (g

([Q[) h

([Q[)).
(v) The Council representative of a Hall y is d(y). Hence the set of Council
representatives of the self-catering Halls is the set of d-images of elements
of J; i.e. the set d([J[). Similarly the set of all Senate representatives of
the self-catering Halls is e([J[). Thus the same student x is a representative
of a self-catering Hall on both Senate and Council if and only if x d([J[)
and x e([J[); i.e. x d([J[) e([J[). Hence the given statement asserts
that the set d([J[) e([J[) has no members; i.e. d([J[) e([J[) = .
(vi) We already know that the set of all students who represent Halls on Senate
is ran e. Similarly ran d is the set of all students who represent Halls on
Council. Thus (ran d)(ran e) is the set of all students who represent Halls
on either Council or Senate (or both). Hence the set of all students who
do not represent their Halls on either Council or Senate is S ((ran d)
(ran e)). The statement says that every student in this set passed the
examination in Chemistry; i.e. for each student x in this set h(x) P.
Hence the statement asserts that the h-image of every element x of the set
S ((ran d) (ran e)) belongs to P; i.e.
h([S ((ran d) (ran e))[) P.
122
6.9 Functions Dened by Formulae
Let f : A B be a partial function. Then, if x domf, x is f-related
to precisely one element of B and this element is denoted by f(x). In many
situations there is a precise rule or formula which may be employed to determine
f(x) whenever x belongs to domf. For example, let f : R R be the total
function such that for every x R x is f-related to x
2
. Then, for each x R,
f(x) = x
2
. Indeed the formula f(x) = x
2
characterizes the function f. [In
elementary mathematics the function is usually identied with the formula and
is simply referred to as the function f(x) = x
2
.] Many functions are determined
by formulae in this way. Consider the formula:
f(x) =
1
x 3
.
If x is a real number and x ,= 3, then f(x) is also a real number. Thus the
formula determines a total function g : R3 R such that, for all x R3,
g(x) =
1
x3
. The formula also gives rise to a partial function h : R R such that
domh = R 3 and whenever x belongs to domh, h(x) =
1
x3
. Although the
functions g and h use the same rule for determining images, they are dierent.
Note that, as sets, g = h. However they are dierent types of function.
Let A = x : N [ 0 x 10, B = x : N [ 0 x 100, C = 1, 3, 5, 7, 9
and D = 2x + 1 x : N [ 0 x 49. Let:
R = (1, 1), (3, 9), (5, 25), (7, 49), (9, 81).
Dene functions f : A B, g : A D, h : C B, k : C D, p : N D,
q : D D, r : C N and s : C R so that:
f = g = h = k = p = q = r = s = R.
Then although as sets the functions f, g, h, k, p, q, r, s are all the same, as func-
tions they are all dierent, since their types are not the same. For example f
is a function from A to B, but g is a function from A to D. The function f is
regarded as a subset of A B; i.e. an object of the power set P(A B); i.e.
an object of type P(A B). Note that each of these functions are associated
with the formula R(x) = x
2
. Thus, for example, f(x) = x
2
for all x domf
and r(x) = x
2
for all x domr. Note that:
domf = domg = domh = domk = domp = domq = domr = doms = C.
and:
ran f = ran g = ran h = ran k = ran p = ran q
= ran r = ran s = 1, 9, 25, 49, 81.
6.10 Composition of Functions
Suppose that A, B, C are three sets and f : A B is a total function from A
to B and g : B C is a total function from B to C. Then, in particular, f
is a relation between A and B and g is a relation between B and C. Hence we
123
may form the relation f
o
9
g between A and C. Suppose that (x, z) f
o
9
g. Then
there exists an element y B such that (x, y) f and (y, z) g. Since f is a
(total) function y is uniquely determined by x; i.e. x is f-related to y and only
y; indeed we may write y = f(x). Similarly z is uniquely determined by y and
we may write z = g(y). Therefore z is uniquely determined by x and we may
write z = g(y) = g(f(x)). This means that f
o
9
g is at least a partial function
from A to C. Moreover, since f is a total function, every element of A has an
f-image in B. Similarly every element of B has a g-image in C. In particular, if
x belongs to A, x has the f-image f(x) in B and f(x) has the g-image g(f(x))
in C and hence x is f
o
9
g-related to f(g(x)). Since this holds for every element
of A, it follows that f
o
9
g is a total function. In this case we may write for all
x A:
(f
o
9
g)(x) = g(f(x)).
For example, suppose that:
A = 0, 1, 2, 3, 4, 5,6, 7, 8, 9, B = p, q, r, s, t, u, v, w,
C = a, b, c, d, e, m, n,
where a, b, c, d, e, m, n, p, q, r, s, t, u, v, w are distinct objects. Suppose that
f : A B is the total function specied by:
f(0) = p, f(1) = r, f(2) = r, f(3) = s, f(4) = t,
f(5) = v, f(6) = t, f(7) = v, f(8) = v, f(9) = w
and suppose that g : B C is the total function specied by:
g(p) = a, g(q) = a, g(r) = a, g(s) = d,
g(t) = b, g(u) = m, g(v) = m, g(w) = m.
Denote f
o
9
g by h. Then:
h(0) = g(f(0)) = g(p) = a, h(5) = g(f(5)) = g(v) = m,
h(1) = g(f(1)) = g(r) = a, h(6) = g(f(6)) = g(t) = b,
h(2) = g(f(2)) = g(r) = a, h(7) = g(f(7)) = g(v) = m,
h(3) = g(f(3)) = g(s) = d, h(8) = g(f(8)) = g(v) = m,
h(4) = g(f(4)) = g(t) = b, h(9) = g(f(9)) = g(w) = m.
We may approach this analysis of h = f
o
9
g from the point of view of relations.
Thus we may write:
f = (0, p), (1, r), (2, r), (3, s), (4, t), (5, v), (6, t), (7, v), (8, v), (9, w);
g = (p, a), (q, a), (r, a), (s, d), (t, b), (u, m), (v, m), (w, m).
Then:
(0, p) f and (p, a) g; (0, a) h;
(1, r) f and (r, a) g; (1, a) h;
(2, r) f and (r, a) g; (2, a) h;
(3, s) f and (s, d) g; (3, d) h;
(4, t) f and (t, b) g; (4, b) h;
124
(5, v) f and (v, m) g; (5, m) h;
(6, t) f and (t, b) g; (6, b) h;
(7, v) f and (v, m) g; (7, m) h;
(8, v) f and (v, m) g; (8, m) h;
(9, w) f and (w, m) g; (9, m) h,
Therefore:
h = (0, a), (1, a), (2, a), (3, d), (4, b), (5, m), (6, b), (7, m), (8, m), (9, m),
so that:
h(0) = a, h(1) = a, h(2) = a, h(3) = d, h(4) = b,
h(5) = m, h(6) = b, h(7) = m, h(8) = m, h(9) = m.
If f : A B and g : B C are total functions we may use an alternative
notation for the composition, f
o
9
g, of f and g. If x A, then the f
o
9
g-image of
x is given by g(f(x)). If we denote f
o
9
g by g f, then the order of f and g are
preserved when we write down the g f-image of an element x of A; thus:
(g f)(x) = (f
o
9
g)(x) = g(f(x)).
The total function g f = f
o
9
g is called the composite of f and g.
Let f : A A be a total function from A to A. Then as a relation f is a
relation on the set A. Hence we may form the relations, f
2
= f
o
9
f, f
3
= f
2
o
9
f,
f
4
= f
3
o
9
f, etc. and these relations are obviously total functions. Moreover, if
x A:
f
2
(x) = (f
o
9
f)(x) = f(f(x));
f
3
(x) = (f
2
o
9
f)(x) = f(f
2
(x)) = f(f(f(x)));
f
4
(x) = (f
3
o
9
f)(x) = f(f
3
(x)) = f(f(f(f(x)))); etc.
For example, if A = 0, 1, 2, 3, 4, 5, 6, 7 and f : A A is the total function
such that:
f(0) = 3, f(1) = 4, f(2) = 6, f(3) = 6,
f(4) = 0, f(5) = 2, f(6) = 1, f(7) = 2.
then:
f
2
(5) = f(f(5)) = f(2) = 6;
f
3
(5) = f(f
2
(5)) = f(6) = 1;
f
4
(5) = f(f
3
(5)) = f(1) = 4; etc.
6.11 Number Ranges
Let a and b be integers. Then we dene the set a . . b by:
a . . b = x : Z [ x a x b.
125
For example:
15 . . 22 = x : Z [ x 15 x 22
= 15, 16, 17, 18, 19, 20, 21, 22;
38 . . 48 = x : Z [ x 38 x 48
= 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58;
(11) . . (4) = 11, 10, 9, 8, 7, 6, 5, 4.
Note that, since there are no integers x such that x 22 and x 15, the set
22 . . 15 is empty. Indeed in general, if a > b, then a . . b = . The notation
a . . b is therefore usually reserved for the case in which a b. In particular
a . . a = a.
6.12 Sequences
Let n be a natural number and let X be a set. Then a total function from 1 . . n
to X is called a sequence, or more precisely a sequence over X. For example, if:
P = Andrew, James, Mary, Sue,
then:
1 Andrew, 2 James, 3 Sue, 4 James
is a sequence (over P). Similarly:
1 Sue, 2 Mary, 3 Andrew, 4 Sue, 5 James,
6 Mary, 7 Sue, 8 Mary, 9 Andrew, 10 James
is a sequence (over P).
If X is a set, then seq X denotes the set of all sequences over X. Let
s seq X. Then, if (r, t) s, t is called the r th term of s. For example, if:
s = 1 Sue, 2 Mary, 3 Andrew, 4 Sue, 5 James,
6 Mary, 7 Sue, 8 Mary, 9 Andrew, 10 James,
then, since (7, Sue) s, Sue is the 7 th term of s. Note also that Sue is the
1 st and 4 th term of s. To specify the sequence s it suces to list its terms
in order:
Sue, Mary, Andrew, Sue, James, Mary, Sue, Mary, Andrew, James.
To distinguish the sequence from the list we delimit the list with the symbols
and ) and write:
s = Sue, Mary, Andrew, Sue, James, Mary, Sue, Mary, Andrew, James).
Although a sequence is in fact a function, we may regard it as an (ordered) list
in this way. Such a list may involve repetitions of elements in the list. Thus,
for example, Sue appears in the above ordered list in three dierent positions.
Let s : 1 . . n X be a sequence, where n is a natural number. Then, if
n 1, it is clear to see that s is a set of n distinct ordered pairs. Thus #s = n.
126
If n = 0, then the set 1 . . n is empty and hence s is empty. Therefore in this
case #s = 0. Thus #s = n for all natural numbers n. If s is empty, we call s
the empty sequence and we write s = ). If s is not empty, we say that s is a
non-empty sequence. Strictly speaking we should distinguish empty sequences
over dierent sets and use dierent notations for them, but usually the context
is clear and no confusion should arise with the notation ).
If we represent a sequence as an (ordered) list, we say that we are writing
out the sequence; for example:
s = Sue, Mary, Andrew, Sue, James, Mary, Sue, Mary, Andrew, James).
but, if we regard the sequence as a set dened by extension, we say that we are
representing the sequence by a list of its elements between braces; for example:
s = 1 Sue, 2 Mary, 3 Andrew, 4 Sue, 5 James,
6 Mary, 7 Sue, 8 Mary, 9 Andrew, 10 James,
or:
s = (1,Sue), (2, Mary), (3, Andrew), (4, Sue), (5, James),
(6, Mary), (7, Sue), (8, Mary), (9, Andrew), (10, James).
6.13 Operations on Sequences
Let s be a sequence. Then rev s denotes the sequence obtained from s by
reversing the order of its terms. For example, if s is the sequence:
Sue, Mary, Andrew, Sue, James, Mary, Sue, Mary, Andrew, James),
then rev s is the sequence:
James, Andrew, Mary, Sue, Mary, James, Sue, Andrew, Mary, Sue).
If s is a non-empty sequence, then:
head s denotes the 1 st (i.e. rst) term of s;
last s denotes the (#s) th (i.e. last) term of s;
front s denotes the sequence obtained from s by removing its last term;
tail s denotes the sequence obtained from s by removing its rst term.
For example if s is the sequence:
Sue, Mary, Andrew, Sue, James, Mary, Sue, Mary, Andrew, James),
then head s is Sue, last s is James, front s is the sequence:
Sue, Mary, Andrew, Sue, James, Mary, Sue, Mary, Andrew),
and tail s is the sequence:
Mary, Andrew, Sue, James, Mary, Sue, Mary, Andrew, James).
127
If s and t are sequences, then s

t is the sequence obtained from s and t
by rst writing out s as a list and then continuing the listing by writing out t.
For example suppose that:
s = Sue, Mary, Andrew, Sue, James);
t = Mary, Sue, Mary, Andrew, James),
then s

t is the sequence:
Sue, Mary, Andrew, Sue, James, Mary, Sue, Mary, Andrew, James),
We call s

t the concatenation of s and t.


Care must be taken in using the set notation for these sequence operations.
For instance we may express the sequence:
s = Sue, Mary, Andrew, Sue, James, Mary, Sue, Mary, ),
in the form:
s = 1 Sue, 2 Mary, 3 Andrew, 4 Sue, 5 James,
6 Mary, 7 Sue, 8 Mary, 9 Andrew.
It would however be wrong to say that tail s is the sequence:
t = 2 Mary, 3 Andrew, 4 Sue, 5 James,
6 Mary, 7 Sue, 8 Mary, 9 Andrew.
Recall that a sequence is a total function of the form s : 1 . . n X, for some
natural number n. Thus the domain of a sequence is always a set of the form
1 . . n, for some natural number n. Note that, however we regard t above as
a total function, its domain cannot contain the natural number 1. Hence t
cannot be a sequence. There are similar dangers in applying the other sequence
operations to sequences represented by sets dened by extension. There is much
less chance of making mistakes if we regard sequences as (ordered) lists when
applying the above operations on them.
A sequence as we have dened it is often referred to as a nite sequence to
distinguish it from an innite sequence. An innite sequence may be dened
as a total function s : N X form the set of all natural numbers N into a set X.
The nth term, s(n), is usually denoted by s
n
and the sequence itself by s
n
.
In this course the word sequence refers exclusively to nite sequences. If we
need to consider an innite sequence we will always add the word innite.
6.14 Functional Overriding
Suppose that f : A B and g : A B are partial functions from a set A to
a set B. Then f and g are relations between A and B. Hence they give rise
to the relation f g between A and B. For the simplicity of notation let us
relabel the relational overriding f g by h. Then, for every element x of A and
every element y of B, (x, y) h if and only if EITHER (x, y) g OR (x, y) f
and x , domg. If (x, y) g, then x domg and y = g(x). If (x, y) f, then
x domf and y = f(x). In either case, if x A, then there is at most one
128
element y of B such that (x, y) h. It follows that h is a partial function from
A to B: h : A B. Then:
x domh
1
y : B (x, y) h

1
y : B (x, y) g ((x, y) f x , domg)
(
1
y : B (x, y)

g) (
1
y : B (x, y) f x , domg)
x domg (x domf x , domg)
x domg x domf domg
x domg (domf domg)
x domg domf.
Therefore
domh = domg domf.
Moreover, if x domh, then h(x) = g(x), if x domg and h(x) = f(x) if
x domf domg.
To recap, if f : A B and g : A B are partial functions, then f g is a
partial function h : A B such that:
domh = domf domg;
h(x) = g(x) if x belongs to domg;
h(x) = f(x) if x belongs to domf but not to domg.
Example. Suppose that A = 0, 1, 2, 3, 4, 5, 6, 7 and B = p, q, r, s, t, u, where
p, q, r, s, t, u are distinct objects. Let f : A B and g : A B be partial
functions given by:
f = 0 s, 2 r, 3 p, 5 q, 6 p;
g = 3 q, 4 s, 5 u, 7 q.
Let h = f g. It is easy to check that:
h = 0 s, 2 r, 3 q, 4 s, 5 u, 6 p, 7 q.
Therefore domh = 0, 2, 3, 4, 5, 6, 7 and:
h(0) = s, h(2) = r, h(3) = p, h(4) = s, h(5) = u, h(6) = p, h(7) = q.
Similarly domf = 0, 2, 3, 5, 6 and:
f(0) = s, f(2) = r, f(3) = p, f(5) = q, f(6) = p,
and domg = 3, 4, 5, 7 and:
g(3) = q, g(4) = s, g(5) = u, g(7) = q.
Then:
(domf) (domg) = 0, 2, 3, 5, 6 3, 4, 5, 7
= 0, 2, 3, 4, 5, 6, 7
= domh.
129
Since:
h(3) = q = g(3), h(4) = s = g(4), h(5) = u = g(5), h(7) = q = g(7),
we see that h(x) = g(x) when x 3, 4, 5, 7 = domg.
Now domf domg = 0, 2, 3, 5, 6 3, 4, 5, 7 = 0, 2, 6. Since:
h(0) = s = f(0), h(2) = r = f(2), h(6) = p = f(6),
we see that h(x) = f(x) for all x 0, 2, 6 = domf domg. This conrms, for
this particular case, the rule:
domh = domf domg;
h(x) = g(x) if x belongs to domg;
h(x) = f(x) if x belongs to domf but not to domg.
6.15 Worked Example
Suppose that we are required to specify the computer program which will control
the operations of an automatic vending machine. The vending machine is able
to retail a certain collection of items which we will denote by Merchandise,
which includes for example a given kind of chocolate bar, denoted by chocolate,
and a certain brand of orange juice contained in a carton, denoted by orange-
juice. The program must involve a database which tells it how much to charge
for each item in the set Merchandise. This database may be expressed as a
partial function:
cost : Merchandise N,
which associates with each item in the domain of the partial function the price
of that item, in pence. Note that perhaps only a small fraction of the items in
the set Merchandise will be on sale at any particular time. Initially only those
items on sale will have a price put on them; the others will only be priced if
and when they are purchased from the wholesaler to be put into the machine
for sale. Therefore there exist items which belong to the set Merchandise, but
not to the domain of cost. If the item chocolate is stocked by the machine and
is to be priced at 39 pence, then:
cost(chocolate) = 39.
On the other hand, if orange-juice is not yet on sale in the machine, then it does
not belong to the domain of cost. At a certain time in the future we may wish
to stock the machine with textorange-juice and hence at the appropriate time
we must enter a corresponding price into the database. Also note that prices
may change from time to time and so occasionally we may need to update the
database with new prices. When the database needs updating we may provide
new instructions to the program by specifying a partial function:
newcost : Merchandise N.
For example, the item orange-juice may be put on sale at a price of 51 pence.
Hence:
newcost(orange-juice) = 51.
130
The items not in the domain of newcost will continue to be priced at their
original value provided they belong to the domain of cost. After this updating
of the database, the machine will be programmed to use the updated price
database given by the partial function:
cost

: Merchandise N,
where:
cost

(x) = newcost(x) if x domnewcost;


cost

(x) = cost(x) if x domcost but x , domnewcost.


The new database dened by cost

gives the price of an item if and only if the


item has a price in the old database dened by cost or has a price in the new
instructions given by newcost. Thus:
domcost

= (domcost) (domnewcost).
It follows that the new database is determined by the partial function:
cost

= cost newcost.
This reects the idea that the new instructions to the program override the
previous ones given by the partial function cost only when there is a conict in
the stated price of an item.
6.16 Bags
The expression N
1
denotes the set N 0; i.e. the set of all natural numbers
other than 0. Thus the set N
1
consists of all the positive integers. A partial
function b : X N
1
from a set X to N
1
is called a bag (or multiset) of elements
of X. For example, if X = p, q, r, s, t, u, v, where p, q, r, s, t, u, v are distinct
objects, then:
q 3, s 2, t 5, v 1
is a partial function from X to N
1
and hence a bag of elements of X.
We may regard a bag as a collection of objects which can contain an object
several times. Thus the bag:
q 3, s 2, t 5, v 1
may be regarded as a collection to which q belongs 3 times, s belongs twice,
t belongs 5 times and v belongs once. In other words we may imagine it as a
shopping bag into which we have put 3 (identical) copies of the object q, 2 copies
of s, 5 copies of t and just one copy of v. We will use the following expression
to denote this bag:
[[q, q, q, s, s, t, t, t, t, t, v]].
It does not matter in which order we write the elements in the bag as long as
each element is listed the required number of times. Thus the same bag may be
expressed as:
[[s, q, t, t, v, s, q, t, t, q, t]].
131
If X is a set, then bag X denotes the set of all bags of elements of X.
Thus bag X is the set of all partial functions from X to N
1
. For example, if
X = p, q, r, s, t, u, v, where p, q, r, s, t, u, v are distinct objects, then:
q 3, s 2, t 5, v 1 = [[q, q, q, s, s, t, t, t, t, t, v, ]]
is an element of bag X.
Example. The concept of bag is of particular use in the context of the vending
machine considered in the previous worked example. Suppose for example the
vending machine contains:
11 bars of chocolate;
9 cartons of orange juice;
12 cartons of grape juice;
18 packets of jelly babies;
10 packets of fruit gums;
6 small packets of biscuits.
Then the contents of the vending machine might be represented by the bag:
chocolate 11, orange-juice 9, grape-juice 12,
jelly-baby 18, fruit-gum 10, biscuit 6.
Note that, in this example, the notation using the symbols [[ and ]] is much too
cumbersome, since there would be, in total, 66 items to list. In this example it
is assumed that:
chocolate, orange-juice, grape-juice,
jelly-baby, fruit-gum, biscuit.
are used as names for particular elements of the set Merchandise. Therefore
the given bag is an element of the set:
bag Merchandise.
There is another obvious bag associated with the vending machine. At any
given moment, there will be a certain collection of coins in the machine. This
collection may be regarded as a bag of elements of N; i.e. as an element of bag N.
Suppose that the machine accepts coins to the value of 1, 2, 5, 10, 20, 50 and
100 pence. At a particular moment in time, the machine contains 15 one-pence
coins, 13 two-pence coins, 18 ten-pence coins, 21 fty-pence coins and 16 pound
coins, but no ve-pence and twenty-pence coins. Then this collection of coins
may be represented by the bag:
1 15, 2 13, 10 18, 50 21, 100 16.
Since this is a partial function from N to N
1
, it is bag of elements of N; i.e. an
element of the set bag N.
If X is a set, then recall that a partial function from X to N
1
is a subset
of X N
1
. In particular the empty set is a subset of X N
1
and hence is a
partial function from X to N
1
. Therefore the empty set may be regarded as
a bag of elements of X. Clearly this bag contains no objects. Thus we call
132
it the empty bag and denote it by [[ ]]. Intuitively it may be thought of as a
shopping bag which has nothing in it at all. We will regard the empty bag as
an element of any set of bags. For instance we may consider it as an element
of bag Merchandise. This empty bag would occur when all the stock of the
vending machine has been sold and none of it has been replaced.
We may classify a bag according to the number of each object it contains.
Suppose that B is a bag of elements of a set X and that x is an element of X.
Let B#x or count Bx to represent the number of copies of x in the bag B. In
terms of the functional notation we have B#x = B(x), if x belongs to domB,
and B#x = 0, otherwise. For example suppose that X = p, q, r, s, t, u, v,
where p, q, r, s, t, u, v are distinct objects, and that B is the bag:
q 3, s 2, t 5, v 1.
Then:
B#p = 0, B#q = 3, B#r = 0, B#s = 2,
B#t = 5, B#u = 0, B#v = 1.
Thus there are no copies of p, three copies of q, no copies of r, two copies of s,
ve copies of t, no copies of u and one copy of v.
6.17 Operations on Bags
Given two shopping bags, it is clear that we may empty them into a single
shopping bag. This process may be applied to our more precise formulation of
bag. Suppose that B and C are bags of elements of a set X. Then we may
dene a bag D of elements of X such that:
D#x = B#x +C#x,
for all x X. In eect we have put the contents of both bags B and C into a
single bag denoted by D. We denote this bag D by BC. For example suppose
that:
X = p, q, r, s, t, u, v;
B = q 3, s 2, t 5, v 1;
C = p 4, q 2, t 3, v 6.
Then B contains:
no copies of p;
3 copies of q;
no copies of r;
2 copies of s;
5 copies of t;
no copies of u;
1 copy of v,
and C contains:
133
4 copies of p;
2 copies of q;
no copies of r;
no copies of s;
3 copies of t;
no copies of u;
6 copy of v.
Hence B C contains:
0 + 4 = 4 copies of p;
3 + 2 = 5 copies of q;
0 + 0 = 0 copies of r;
2 + 0 = 2 copies of s;
5 + 3 = 8 copies of t;
0 + 0 = 0 copies of u;
1 + 6 = 7 copies of v.
Therefore:
B C = p 4, q 5, s 2, t 8, v 7.
Consider the example of the vending machine. Suppose that at a particular
time the bag which represents the contents of the machine is:
B = chocolate 11, orange-juice 9, grape-juice 12,
jelly-baby 18, fruit-gum 10, biscuit 6.
Suppose that additional items were then added to the contents of the vending
machine. To be precise suppose that these items were represented by the bag:
C = orange-juice 20, fruit-gum 15, biscuit 10
crisp 17, humbug 23,
where crisp denotes a packet of crisps and humbug denotes a packet of humbugs.
Then B C is the bag D of elements of merchandise such that:
D#x = B#x +C#x,
for all elements x of Merchandise. Now D#x = 0 for all x in Merchandise
except for the following cases:
D#chocolate = 11 + 0 = 11;
D#orange-juice = 9 + 20 = 29;
D#grape-juice = 12 + 0 = 12;
D#jelly-baby = 18 + 0 = 18;
D#fruit-gum = 10 + 15 = 25;
D#biscuit = 6 + 10 = 16;
D#crisp = 0 + 17 = 17;
D#humbug = 0 + 23 = 23.
Therefore:
B C = chocolate 11, orange-juice 29, grape-juice 12,
jelly-baby 18, fruit-gum 25, biscuit 16,
crisp 17, humbug 23.
134
The example of a vending machine also suggests another possible operation
on bags. Suppose that we consider the removal of items from the vending
machine for whatever purpose [they may have been sold, or perhaps they have
passed a sale-by-date]. For example suppose that the bag:
B = chocolate 11, orange-juice 9, grape-juice 12,
jelly-baby 18, fruit-gum 10, biscuit 6.
represents the contents of the machine at a certain time. Suppose over a short
period of time certain of these contents have been removed. To be precise,
suppose that those items removed are given by the bag:
E = chocolate 6, orange-juice 9, jelly-baby 3, biscuit 4.
The bag which represents what is left is denoted by B

E; thus:
B

E = chocolate 5, grape-juice 12, jelly-baby 15,
fruit-gum 10, biscuit 2.
More generally, if B and C are bags of elements of the set X and C is such
that:
B#x C#x,
for every element x of X, then we may dene B

C as that bag of elements G
of X such that:
G#x = B#x C#x,
for all x in X. However, since B C is dened for ALL bags of elements of
X, we would like the same to be true for B

C. Let us consider the above
example. Suppose that a customer would like to buy from the vending machine
items represented by the bag:
F = chocolate 5, orange-juice 9, jelly-baby 3, biscuit 13.
If the stock of the vending machine is represented by the bag B above, then
there are insucient packets of biscuits in the vending machine to satisfy the
customers needs. The best that the customer can achieve is to purchase all the
packets of biscuits in the machine; namely 4 packets. In this case the resulting
stock of the machine is given by the bag:
G = chocolate 6, grape-juice 12, jelly-baby 15, fruit-gum 10.
Again in this case we use the same notation and denote G by B

F. Therefore,
in general, for ANY bags, B and C of elements of X, we dene B

C to be the
bag G of elements of X such that, for every element x of X:
G#x =

(B#x) (C#x) if B#x C#x


0 if B#x < C#x
135

Вам также может понравиться