Escolar Documentos
Profissional Documentos
Cultura Documentos
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
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
:
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
= domR.
For:
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[) = 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[) = 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, , , =, , (, ),
([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 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
: 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
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
: B A is given by:
k
and f
is a partial function, x = f
(y).
Thus, if y ran f, then 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
: B A.
Now suppose that f : A B is a total function. We now investigate under
what conditions the inverse relation 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
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
= ran f = B.
Thus f
is
injective. Also, since:
ran f
= domf = A,
f
is surjective. Since 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
([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[) = 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[) = 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[).
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[) h
([Q[).
It follows that Mary qualies for a prize if she belongs to either the set
f
([Q[) h
([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
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
= (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 =