c1 3 Languagerelation&Functions
c1 3 Languagerelation&Functions
There are many kinds of relationships in the world. For instance, we say that two people are related by blood if
they share a common ancestor and that they are related by marriage if one shares a common ancestor with the
spouse of the other. We also speak of the rela-tionship between student and teacher, between people who work
for the same employer, and between people who share a common ethnic background.
Similarly, the objects of mathematics may be related in various ways. A set A may be said to be related to a set
B if A is a subset of B, o r i f A is not a subset of B, o r i f A and B have at least one element in common. A
number x may be said to be related to a number y if x < y, o r i f x is a factor of y, o r i f x2 + y2 = 1. Two
identifiers in a computer
program may be said to be related if they have the same first eight characters, or if the same memory location is
used to store their values when the program is executed. And the list could go on!
Let A = { 0, 1, 2} and B = { 1, 2, 3} and let us say that an element x in A is related to an element y in B if, and
only if, x is less than y. Let us use the notation x R y as a shorthand for the sentence “x is related to y.” Then
On the other hand, if the notation x R y represents the sentence “x is not related to y,”
then
1 R 1 since 1 < 1,
2 R 1 since 2 < 1, and
2 R 2 since 2 <
2.
Recall that the Cartesian product of A and B, A × B, consists of all ordered pairs
whose first element is in A and whose second element is in B:
A × B = (x, y) | x ∈ A and y ∈ B .
In this case,
A × B = (0, 1) , (0, 2), (0, 3), (1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3) .
The elements of some ordered pairs in A × B are related, whereas the elements of other
ordered pairs are not. Consider the set of all ordered pairs in A × B whose elements are
related
(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3) .
Observe that knowing which ordered pairs lie in this set is equivalent to knowing which
elements are related to which. The relation itself can therefore be thought of as the totality
of ordered pairs whose elements are related by the given condition. The formal mathe-
matical definition of relation, based on this idea, was introduced by the American math-
ematician and logician C. S. Peirce in the nineteenth century.
• Definition
Let A and B be sets. A relation R from A to B is a subset of A × B. Given an
ordered pair (x, y) in A × B, x is related to y by R, written x R y, if, and only
if, (x, y) is in R. The set A is called the domain of R and the set B is called its
co-domain.
c.
y
x2 + y2 = 1
–1 1 x
2 3 2 3
3 5 3 5
These example relations illustrate that it is possible to have several arrows coming
out of the same element of A pointing in different directions. Also, it is quite possible to
have an element of A that does not have an arrow coming out of it. ■
Functions
In Section 1.2 we showed that ordered pairs can be defined in terms of sets and we defined
Cartesian products in terms of ordered pairs. In this section we introduced relations as
subsets of Cartesian products. Thus we can now define functions in a way that depends
only on the concept of set. Although this definition is not obviously related to the way
we usually work with functions in mathematics, it is satisfying from a theoretical point
1.3 The Language of Relations and Functions 17
of view and computer scientists like it because it is particularly well suited for operating
with functions on a computer.
• Definition
A function F from a set A to a set B is a relation with domain A and co-domain B
that satisfies the following two properties:
1. For every element x in A, there is an element y in B such that (x, y) ∈ F.
2. For all elements x in A and y and z in B,
if (x, y) ∈ F and (x, z) ∈ F, then y = z.
Properties (1) and (2) can be stated less formally as follows: A relation F from A to
B is a function if, and only if:
1. Every element of A is the first element of an ordered pair of F.
2. No two distinct ordered pairs in F have the same first element.
In most mathematical situations we think of a function as sending elements from one
set, the domain, to elements of another set, the co-domain. Because of the definition of
function, each element in the domain corresponds to one and only one element of the
co-domain.
More precisely, if F is a function from a set A to a set B, then given any element x in
A, property (1) from the function definition guarantees that there is at least one element
of B that is related to x by F and property (2) guarantees that there is at most one such
element. This makes it possible to give the element that corresponds to x a special name.
• Notation
If A and B are sets and F is a function from A to B, then given any element x in
A, the unique element in B that is related to x by F is denoted F(x), which is read
“F of x.”
A B
2 1
4 3
6 5
18 Chapter 1 Speaking Mathematically
Solution
a. R is not a function because it does not satisfy property (2). The ordered pairs (4, 1)
and (4, 3) have the same first element but different second elements. You can see this
graphically if you draw the arrow diagram for R. There are two arrows coming out of
4: One points to 1 and the other points to 3.
A B
R
2 1
4 3
6 5
b. S is not a function because it does not satisfy property (1). It is not true that every
element of A is the first element of an ordered pair in S. For example, 6 ∈ A but there
is no y in B such that y = 6 + 1 = 7. You can also see this graphically by drawing
the arrow diagram for S.
A B
S
2 1
4 3
Solution
a. The graph of C, shown on the next page, indicates that C does not satisfy either func-
tion property. To see why C does not satisfy property (1), observe that there are many
real numbers x such that (x, y) ∈
/ C for any y.
1.3 The Language of Relations and Functions 19
x2 + y2 = 1
( 1 , √3
2 2 )
Graph of C
x=2
( 1,
2
– √3
2 )
x = 12
y=x–1
(x, 0)
Graph of L
Function Machines
Another useful way to think of a function is as a machine. Suppose f is a function from X
to Y and an input x of X is given. Imagine f to be a machine that processes x in a certain
way to produce the output f (x). This is illustrated in Figure 1.3.1 on the next page.
20 Chapter 1 Speaking Mathematically
x
Input
function machine
f (x) Output
Figure 1.3.1
x n r
Figure 1.3.2 ■
f equals g, written f = g, if, and only if, f (x) = g(x) for all x in A.
1.3 The Language of Relations and Functions 21