chapter 6 functions and relationschapter 6 functions and relations 6.1 cartesian products in the...

27
Chapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-y plane), we associate the set of points in the plane with the set of all ordered points (x, y), where x and y are both real numbers. The idea of a Cartesian product of sets replaces R in the description by some other set(s), and drops the geometric interpretation. If A and B are sets, the Cartesian product of A and B is the set A × B = {(a, b):(a A) and (b B)}. The following points are worth special attention: The Cartesian product of two sets is a set. The elements of that set are ordered pairs. In each ordered pair, the first component is an element of A, and the second component is an element of B. The points in the x-y plane correspond to the elements of the set R × R. For example, if A = {1, 2, 3} and B = {a, b}, then A × B = {(1,a), (1,b), (2,a), (2,b), (3,a), (3,b)} and B×A = {(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3)}. Suppose A has m elements and B has n elements. Then, each element of A is the first component of n ordered pairs in A × B: one for each element 1

Upload: others

Post on 01-Apr-2021

5 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

Chapter 6

Functions and Relations

6.1 Cartesian Products

In the Cartesian plane (or x-y plane), we associate the set of points in theplane with the set of all ordered points (x, y), where x and y are both realnumbers. The idea of a Cartesian product of sets replaces R in the descriptionby some other set(s), and drops the geometric interpretation.

If A and B are sets, the Cartesian product of A and B is the set

A×B = {(a, b) : (a ∈ A) and (b ∈ B)}.

The following points are worth special attention:

• The Cartesian product of two sets is a set.

• The elements of that set are ordered pairs.

• In each ordered pair, the first component is an element of A, and thesecond component is an element of B.

The points in the x-y plane correspond to the elements of the set R×R.

For example, if A = {1, 2, 3} and B = {a, b}, then A×B = {(1, a), (1, b),(2, a), (2, b), (3, a), (3, b)} andB×A = {(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3)}.

Suppose A has m elements and B has n elements. Then, each element ofA is the first component of n ordered pairs in A × B: one for each element

1

Page 2: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

2 CHAPTER 6. FUNCTIONS AND RELATIONS

of B. Thus the number of elements in A × B equals m × n, the number ofelements in A times the number of elements in B. This is one way in whichthe “×” symbol is suggestive notation for the Cartesian product.

What should A × ∅ be? By definition, it is the set of all ordered pairs(a, b) where a ∈ A and b ∈ ∅. There are no such pairs, as there are noelements b ∈ ∅. Hence A× ∅ = ∅. Similarly, ∅ ×B = ∅.

We says that two ordered pairs are equal if the first components areidentical and so are the second components. That is, (a, b) = (c, d) if andonly if a = c and b = d. This corresponds to (and generalizes) our idea ofequality for ordered pairs of real numbers.

The example above shows that A × B 6= B × A in general. This leadsto the question of when they are equal. Certainly they are equal if A = Bbecause then A× B = A× A = B × A. They are also equal when A = ∅ orB = ∅ because, then A× B = ∅ = B × A. We now show that these are theonly possibilities where equality can hold.

Proposition 6.1.1 Let A and B be sets. Then A×B = B ×A if and onlyif A = B, or A = ∅, or B = ∅.

Proof. (⇒) We prove the contrapositive. Suppose A and B are non-emptysets such that A 6= B. Then one of them has an element which does notbelong to the other. Suppose first that there exists x ∈ A such that x 6∈ B.Since B 6= ∅, the set A × B has an ordered pair with first component x,whereas B × A has no such ordered pair. Thus A × B 6= B × A. Theargument is similar in the other case, when there exists y ∈ B such thaty 6∈ A.

(⇐). If A = B then A × B = A × A = B × A. If A = ∅, thenA×B = ∅ = B × A. The case where B = ∅ is similar. �

The set A×(B∪C) is the set of all ordered pairs where the first componentis an element of A, and the second component is an element of B ∪C. Thatis, the second component is an element of B or an element of C. This is thesame collection that would be obtained from the union (A × B) ∪ (A × C),which is made from the union of the set of all ordered pairs where the firstcomponent is an element of A and the second component is an element of B,and the set of all ordered pairs where the first component is an element of

Page 3: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.1. CARTESIAN PRODUCTS 3

A, and the second component is an element of C. This is the outline of theproof of the following proposition.

Proposition 6.1.2 Let A,B and C be sets. Then, A× (B∪C) = (A×B)∪(A× C).

Proof. (LHS ⊆ RHS) Let (x, y) ∈ A×(B∪C). Then x ∈ A and y ∈ (B∪C).That is, y ∈ B or y ∈ C. This leads to two cases. If y ∈ B, then (x, y) ∈A×B, and so (x, y) ∈ (A×B)∪ (A×C). If y ∈ C, then (x, y) ∈ A×C, andso (x, y) ∈ (A×B)∪ (A×C). Therefore, A× (B ∪C) ⊆ (A×B)∪ (A×C).

(RHS ⊆ LHS) Let (x, y) ∈ (A × B) ∪ (A × C). Then (x, y) ∈ A × Bor (x, y) ∈ A × C. This leads to two cases. If (x, y) ∈ A × B, then x ∈ Aand y ∈ B. Since y ∈ B, we have y ∈ B ∪ C, so (x, y) ∈ A × (B ∪ C). If(x, y) ∈ A× C, then x ∈ A and y ∈ C. Since y ∈ C, we have y ∈ B ∪ C, so(x, y) ∈ A× (B ∪ C). Therefore, (A×B) ∪ (A× C) ⊆ A× (B ∪ C). �

The proposition above can also be proved using set builder notation andshowing that the two sets are described by logically equivalent expressions.One hint that this is so is in the informal proof outline that precedes theproposition. Another one is in the proof of the proposition: the second partof the proof above is essentially the first part written from bottom to top.Each step is an equivalence rather than just an implication.

The same methods can be used to prove the following similar statements:

• A× (B ∩ C) = (A×B) ∩ (A× C);

• (A ∪B)× C = (A× C) ∪ (B × C);

• (A ∩B)× C = (A× C) ∩ (B × C).

It is a good exercise to investigate, then prove or disprove as appropriate,similar statements involving the Cartesian product and operations like setdifference, A \B, and symmetric difference, A⊕B.

Page 4: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

4 CHAPTER 6. FUNCTIONS AND RELATIONS

6.2 Functions: the definition and some ter-

minology

The goal of this section is to talk about functions from a set A to a set B bygeneralizing the corresponding concepts from real valued functions of a realvariable to this slightly different setting.

One description of a real-valued function of a real variable is that it is arule that associates exactly one (output) real number y = f(x) with every(input) real number x for which the function is defined. Sometimes “way ofassociating” is used in place of “rule that associates”. But this isn’t great.What, exactly, is a rule? And what is the “way”? We will get there byregarding a function as a collection of ordered pairs.

A function y = f(x) corresponds to curve in the x-y plane that passesthe vertical line test : for any real number x, the vertical line passing throughx meets the curve in at most one point. If it does, then the domain of f isthe set of all points x where the vertical line passing through x meets thegraph (exactly once). This is the set of all numbers x at which the functionis defined. The range of f is the set of all points y where the horizontalline passing through y meets the graph at least once. This is the set ofall numbers y that occur as a value of the function, that is, are such thaty = f(x) for some x.

The graph of the function f is the set of all points (x, f(x)), where x is inthe domain of f . Passing the vertical line test is equivalent to the graph off containing exactly one ordered pair with first component x, for every x inthe domain. This collection of points completely describes the function: thedomain is the set of all numbers x that occur as the first component of anordered pair in the collection, and the range is the set of all values that occuras the second component of an ordered pair in this collection. Further, thisset of points explicitly gives the association between each x in the domainand the corresponding value f(x) in the range.

Let A and B be sets. A function f from A to B, denoted f : A→ B, isa subset f ⊆ A×B in which, for every a ∈ A, there exists exactly one b ∈ Bsuch that (a, b) ∈ f .

Here are some points worth remembering.

Page 5: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.2. FUNCTIONS: THE DEFINITION AND SOME TERMINOLOGY 5

• A function from A to B is a special kind of subset of A×B.

• Each element a ∈ A is the first component of exactly one ordered pair inthe function. Thus (for finite sets) the number of ordered pairs equalsthe number of of elements of A.

• There are no restrictions on how elements of B occur as the secondcomponents of ordered pairs in a function. In particular, there is noguarantee that any given element ofB appears as the second componentof any ordered pair.

Let A = {1, 2, 3, 4} and B = {a, b, c}. The relation f1 = {(1, a), (2, a),(3, b), (4, b), (1, b)} fails to be a function because it contains two ordered pairswith first component 1. The relation f2 = {(2, a), (4, b), (1, b)} fails to be afunction because there is no ordered pair with first component 3. For thesesets A and B, a function from A to B is a set consisting of exactly fourordered pairs; {(1, ), (2, ), (3, ), (4, )}, where each blank is filled in withsome element of B.

Let’s count the number of functions from A to B for the sets A and Bin the previous paragraph. There are 3 options for the element of B to putin the first blank. For each of there, there are three options for the elementof B to put in the second blank. For each of these nine options, are threeoptions for the element of B to put in the third blank. And for each of these27 options, reasoning in the same way gives that there are 81 = 34 functionsfrom A to B.

If A has m elements and B has n elements, then similar reasoning givesthat there are nm functions from A to B.

Let f : A → B be a function. Here is some notation and terminologythat is commonly used so that it is possible to communicate ideas aboutfunctions.

• The set A is called the domain of f . To the extent that the elementsof A are regarded as inputs and the elements of B are regarded asoutputs, the domain is where the inputs live.

• The set B is called the target (or, more commonly, the co-domain).The term target is suggestive if you remember that it is where thearrow is pointed.

Page 6: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6 CHAPTER 6. FUNCTIONS AND RELATIONS

• If (a, b) ∈ f , then the element b is called the image of a under f , orthe value of f at a, and is denoted by f(a). The element a is calleda preimage of b. Notice that it is “a” preimage, not “the” preimage; bcould be f(a) for several elements of a.

• The range of f is the set rng f of elements of B that are values of f .That is, rng f = {b ∈ B : b = f(a) for some a ∈ A}. It is easy toremember the term “range” if you think of it as suggesting the values off range over the elements in this set. The notation f(A) is sometimesused to denote the range of f .

Let A be the set of all faculty and students at UVic, and let B be the setof all amounts of money in dollars and cents. Let f be the relation from Ato B where (a, b) ∈ f ⇔ person a ∈ A owes amount b to the library. Sincefor every person a ∈ A there is a unique amount of money that s/he owes tothe library (possibly $0), f is a function. The domain of f is A, its target isB, and its range is the set of all amounts of money that are owed (each byat least one person). If (Gary, $1.59) ∈ f , then f(Gary) = $1.59, the imageof Gary is $1.59, a pre-image of $1.59 is Gary, and the amount $1.59 belongsto the range of f . (Note: any person who owes $1.59 to the library is also apre-image of $1.59.)

To conclude this section, let f : R→ Z be defined by f(x) = d2xe+b2xc.Let’s determine rng f . We begin by testing a few values of x:

• f(0) = 0;

• If x ∈ (0, 1/2), then 2x ∈ (0, 1) so d2xe = 1 and b2xc = 0, hencef(x) = 1;

• f(1/2) = 2;

• If x ∈ (1/2, 1) then 2x ∈ (1, 2) d2xe = 2 and b2xc = 1, hence f(x) = 3;

• f(1) = 4;

• If x ∈ (1, 3/2), then 2x ∈ (2, 3) so d2xe = 3 and b2xc = 2, hencef(x) = 5.

• f(3/2) = 6.

Page 7: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.3. EQUALITY OF FUNCTIONS 7

Based on these computations, it seems reasonable to guess that the rangeof f is Z. We prove that this is the case. First, observe that f(x) is aninteger for every x ∈ R, so rng f ⊆ Z. To show the opposite inclusion,let y ∈ Z. We must find x ∈ R such that f(x) = y. If y is even, sayy = 2t, t ∈ Z, then f(t/2) = d2t/2e + b2t/2c = 2t = y. If y is odd, sayy = 2t + 1, t ∈ Z, then for any x ∈ (t/2, t/2 + 1/2) we have 2x ∈ (t, t + 1),hence f(x) = (t+ 1) + t = 2t+ 1 = y. Hence the range of f is Z.

6.3 Equality of functions

Recalling the definition of a function as a set of ordered pairs, it makes sensethat two functions should be equal if they are described by the same set ofordered pairs. This means that they have the same domain, A (because thereis one ordered pair corresponding to each element of the same domain) and,for each a ∈ A, they have the same value at a. However, we can only have arelation from a set A to a set B if the set B is also known. This leads to thefollowing definition.

Two functions f and g are equal if

• they have the same domain,

• they have the same target, and

• f(x) = g(x) for every x in the domain.

Thus, according to the definition, the following pairs of functions are notequal:

• f : R→ Z defined by f(x) = bxc, and g : Z→ Z defined by g(x) = bxc.

• f : R→ R defined by f(x) = bxc, and g : R→ Z defined by g(x) = bxc.

• f : R→ R defined by f(x) = bxc, and g : R→ Z defined by g(x) = dxe.

6.4 1-1 functions and onto functions

The condition that determines whether a given relation is a function is aboutelements of A only. The conditions below that determine if a given function

Page 8: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

8 CHAPTER 6. FUNCTIONS AND RELATIONS

is 1-1 or onto are about elements of B only. That is, in the definition of afunction we focus on what happens with respect to elements of the domain.With these properties of functions we focus on what happens to elements ofthe target.

Informally, a function f is called one to one, or 1-1, if different inputsproduce different outputs, or if each output value arises from a unique inputvalue. For real valued functions of a real variable, this is equivalent to thehorizontal line passing through y meeting the graph of f in at most one point,for every y ∈ R (or, meeting the graph in exactly one point, for every y inthe range of f). More formally, f is 1-1 if x1 6= x2, then f(x1) 6= f(x2).

The contrapositive of the previous statement is if f(x1) = f(x2), thenx1 = x2. Throughout mathematics, this is a common method used to showsomething is unique: assume there are two and argue that they must actuallybe the same. Here we would be assuming that the same output arises formtwo different inputs, and arguing that those inputs are actually the same (sothere is only one).

Informally, a real-valued function of a real variable, f , is called onto if,for every y ∈ R horizontal line passing through y meets the graph of f in atleast one point. More formally, f is onto if for every y ∈ R there is an x inthe domain of f such that y = f(x).

We now generalize these concepts to functions from a set A to a set B.

Let f : A→ B be a function.

• f is called one to one, or 1-1, or injective, if every element of B is thesecond component of at most one element of am ordered pair in f . Thisis equivalent to the statement that if x1 6= x2, then f(x1) 6= f(x2), andalso to its contrapositive: if f(x1) = f(x2) then x1 = x2.

• f is called onto. or surjective if for every b ∈ B there is an a ∈ A suchthat (a, b) ∈ f .

• A function that is both injective (1-1) and surjective (onto) is some-times called bijective.

How can you remember injective, surjective and bijective? Functions thatare 1-1 go “in” to the target in separate places, the French word for on is“sur”, and a bi -jection enjoys both properties.

Page 9: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.4. 1-1 FUNCTIONS AND ONTO FUNCTIONS 9

If A has more elements then B, then no function f from A to B can be1-1. There are more ordered pairs in f than there are elements of B, so someelement of B must appear in two of them.

Similarly, if A has fewer elements than B, then no function f from A toB can be onto. There are fewer ordered pairs in f than there are elements ofB, some element of B must not appear in any of them.

The best way to prove a function f is 1-1 is to use the condition iff(x1) = f(x2) then x1 = x2. That is, to argue that if b is a value of thefunction, then there is a unique a ∈ A such that f(a) = b. As we mentionedpreviously, throughout mathematics the same method is used to prove anobject is unique: assume there are two, and argue that they are in fact thesame.

To prove that a function f is not 1-1, find distinct elements x1 and x2 inthe domain so that f(x1) = f(x2). By doing this, you have demonstratedthat the implication (f(x1) = f(x2)) → (x1 = x2) is False, and so f is not1-1..

Suppose f : R → R is defined by f(x) = 2x + 5. To show that f is 1-1,argue as follows. Suppose f(x1) = f(x2). Then 2x1 + 5 = 2x2 + 5 and, aftersome algebra, x1 = x2.

If it is not possible to show a function f is not 1-1 by easily identifyingelements x1 and x2 in the domain so that f(x1) = f(x2), then start tryingto prove that f is 1-1. If f isn’t 1-1, then the proof will break down at somepoint, and this will lead to the required elements. For example, supposef : R → R is defined by f(x) = (x + 4)2. It turns out that f is not 1-1 because, for example, f(0) = f(−8), but suppose we did not see thatand, instead, tried to prove that f is 1-1: Suppose f(x1) = f(x2). Then(x1 + 4)2 = (x2 + 4)2, so that |x1 + 4| =

√(x1 + 4)2 =

√(x2 + 4)2 = |x2 + 4|.

The presence of the absolute value is a clue that there may be more than onevalue in the domain corresponding to a particular value in the range. Here,if we let x1 = 0 (note that x1 is in the domain) then we get 4 = |x2 + 4|.Checking the two cases in the definition of absolute value gives the twosolutions x2 = 0 (in the case x2 ≥ 0) or x2 = −8 (in the case x2 < 0). Bothof these values are in the domain, and substituting them into the formulafor f shows that they have the same image. There is nothing special aboutthe choice of 0 except that it is possible to see up front that choosing it willserve our purposes. To show that f is not 1-1 we need to find one value in

Page 10: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

10 CHAPTER 6. FUNCTIONS AND RELATIONS

the range that is associated with two different elements of the domain.

If a function is not 1-1, then it is always possible to restrict its domain toget a new function that is 1-1. In the example above, if the domain is replacedby [−4,∞) = {x : x ≥ −4}, then the new function f : [−4,∞)→ R, definedby f(x) = (x + 4)2, is 1-1. To see this, suppose f(x1) = f(x2). Then(x1 + 4)2 = (x2 + 4)2, so that |x1 + 4| = |x2 + 4|. But x1, x2 ∈ [−4,∞), sox1 +4 ≥ 0 and x2 +4 ≥ 0. Hence x1 +4 = x2 +4. It now follows that x1 = x2and this function f is 1-1.

The best way to prove a function f is onto is constructive. Given b ∈ B,somehow use the information given to find a ∈ A such that f(a) = b. Whenf is given by a formula giving b as the value of an expression involving a,this amounts to solving the equation b = f(a) for a.

To prove that a function is not onto you must find an element b ∈ Bwhich is not f(a) for any a ∈ A. How you do this depends on f . In general,it is useful to try to prove that f is onto as above. If it isn’t onto, then youwill reach a point where either you can’t solve for a in terms of b, or you willsucceed in doing this but the only possibilities you find are not elements of A.In either case you are done as it will have been shown that the assumptionf is onto leads to (logically implies) a contradiction. Thus by the inferencerule Proof by Contradiction it must be that the assumption that f is notonto.

Suppose f : R → R is defined by f(x) = 2x + 5. To show that f isonto, argue as follows. Take any y ∈ R. If y = f(x) then y = 2x + 5 and,after some algebra, x = (y − 5)/2. This says that if y is f(x), then x mustequal (y − 5)/2. For any y ∈ R we have x = (y − 5)/2 ∈ R and, furtherf(y − 5)/2 = 2(y − 5)/2 + 5 = y. Hence f is onto.

The function f above is not onto when the domain and target are replacedby Z. To see this, argue as before to get that y = f(x) implies x = (y−5)/2.Buy it is possible to choose y in the target so that (y − 5)/2 is not in thedomain. For example, if y = 6 then (y− 5)/2 = 1/2 6∈ Z. Hence there is notx ∈ Z to that f(x) = 6, and this function f is not onto.

As another example, we show that the function f : (0,∞) → (0,∞)defined by f(x) = −27 + (x + 3)3 is onto. Let y ∈ (0,∞). Then f(x) =y ⇔ −27 + (x + 3)3 = y ⇔ (x + 3)3 = y + 27 ⇔ x + 3 = 3

√y + 27. (Every

number has a unique cube root.) We must verify that this x belongs to

Page 11: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.5. FUNCTION COMPOSITION 11

the domain. Since y ∈ (0,∞) we have y + 27 > 27 and 3√y + 27 > 3.

Therefore −3 + 3√y + 27 ∈ (0,∞). Hence, if x = −3 + 3

√y + 27, then f(x) =

−9 + ((−3 + 3√y + 27) + 3)3 = −27 + ( 3

√y + 27)2 = y, and so f is onto.

Now suppose f : R→ R is defined by f(x) = (x+ 4)2. It turns out thatf is not onto. We can observe that f(x) ≥ 0 for all x, thus there can’t be anx for which f(x) = −1. Suppose we did not notice that and, instead, triedto prove that f is onto: Take any y ∈ R. If y = f(x), then y = (x + 4)2, sothat

√y = |x + 4|. The left hand side of this expression is not defined for

all y ∈ R: no real number is the square root of a negative number. Hence, ify < 0, then there is no real number x for which f(x) = y, and this functionf is not onto.

If a function is not onto, the new function obtained by replacing the targetby the range is onto. In the example above the function f : R → [0,∞)defined by f(x) = (x + 4)2 is onto. To see this, argue as before. Take anyy ∈ [0,∞). If y = f(x), then y = (x + 4)2, so that

√y = |x + 4|. Since

y ≥ 0, the square root of y exists. If x + 4 ≥ 0 we have x = −4 +√y, and

if x + 4 < 0 we have x = −4 − √y. Since both −4 +√y and −4 − √y are

in the domain (though we only need one of them to be in the domain) andf(−4 +

√y) = f(4−√y) = y, this function f is onto.

To illustrate the parenthetical comment in the last sentence of the pre-vious paragraph, show (for yourself) that f : (−∞,−4]→ [0,∞) defined byf(x) = (x+ 4)2 is onto. The argument is identical to the one on the previousparagraph up to the last sentence.

6.5 Function composition

In calculus, the chain rule tells us how to differentiate a function of the formg(f(x)), that is, a function which is the composition of two different realvalued functions of a real variable. The value of such a function is obtainedby first evaluating f to get a number y, and then finding g(y). The purposeof this section is to extend the idea of using one function and then anotherto functions between arbitrary sets.

Let A,B and C be sets, and f : A→ B and g : B → C be functions. Thecomposition of f and g is the function g ◦ f : A → C defined by g ◦ f(a) =g(f(a)), for every element a in A.

Page 12: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

12 CHAPTER 6. FUNCTIONS AND RELATIONS

For example, suppose A = {1, 2, 3}, B = {a, b, d, e} and C = {w, z}.Let f : A → B be f = {(1, b), (2, e), (3, a)}, and g : B → C be g ={(a, w), (b, z), (d, z), (e, z)}. Then g ◦ f : A → C is defined. The valueg ◦ f(1) = g(f(1)) = f(b) = z. Similar reasoning for 2 and 3 gives thatg ◦ f = {(1, z), (2, z), (3, w)}. Notice that f ◦ g is not defined because g(x) isan element of C and f applies to elements of A.

Order matters in function composition. This is clear in the previousexample because g ◦ f is defined and f ◦ g is not defined. Even in caseswhere both are defined, they are usually different functions, as the followingexample shows. Let f : Z → Z be defined by f(x) = x2 and g : Z → Z bedefined by g(x) = x+3. Both g◦f and f ◦g have domain Z and target Z. Butthey don’t have the same values: since g ◦ f(x) = g(f(x)) = g(x2) = x2 + 3and f ◦ g(x) = f(g(x)) = f(x + 3) = (x + 3)2 = x2 + 6x + 9, we haveg ◦ f(0) = 3 and f ◦ g(0) = 9. Thus, g ◦ f 6= f ◦ g.

6.6 The identity function

In the arithmetic of real numbers, 0 is an identity for addition: x + 0 = xfor all real numbers x (adding zero does not change anything). Further,the additive inverse of x (i.e. its negative) is the number −x such thatx + (−x) = 0 (the sum is the additive identity). Similarly, 1 is an identityfor multiplication: 1x = x for all real numbers x. The multiplicative inverseof a non-zero number x (i.e. its reciprocal) is the number 1/x such thatx(1/x) = 1 (the product is the multiplicative identity).

In this section we describe an identity for function composition. If thereis such a function, it should have the property that it changes nothing when“its” operation is applied, just like identities for addition and multiplicationin real numbers. That is, we want an “identity function” to have the propertythat the result of composing it with a function f is the function f . In thenext section we will relate this identity to inverses of functions.

Let A be a set. The identity function on A is the function ιA : A → Adefined by ιA(a) = a for every a ∈ A.

The identity function does absolutely nothing in the sense that it sendsevery element of A to itself. It is an easy exercise to check that ιA is 1-1 andonto.

Page 13: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.7. INVERSE FUNCTIONS 13

The following proposition shows that identity functions have the propertywe would like in an identity. Two different identity functions appear becausea function’s domain can be different than its target, and it is important tomake sure that the composition is defined.

Proposition 6.6.1 Let A and B be sets, and f : A → B a function. Thenf ◦ ιA = f and ιB ◦ f = f .

Proof. We prove only the first statement. The proof of the second statementis similar. Since ιA : A → A, we have f ◦ ιA : A → B, so this function hasthe same domain and target as f . It remains to show it has exactly the samevalues. Take any a ∈ A. Then f ◦ ιA(a) = f(ιA(a)) = f(a). This completesthe proof. �

6.7 Inverse functions

By analogy with additive inverses and multiplicative inverses for real numbers(see the discussion at the start of the last section), an inverse for a functionf : A → B should be a function g : B → A such that g ◦ f = ιA. Thatis, the function g should have the property that f(a) = b ⇔ g(b) = a. Ifthis happens, then f should also be an inverse for g, and so we should havef ◦ g = ιB.

Formally, we define functions f : A→ B and g : B → A to be inverses iff(a) = b⇔ g(b) = a. Equivalently, f : A→ B and g : B → A are inverses ifg ◦ f = ιA and f ◦ g = ιB.

Hidden in the definition is the condition that if f and g are inverses, thenthat the target of f is the domain of g, and the domain of f is the target ofg.

The equivalent statement of the definition gives a method for checkingif functions f and g are inverses: show that g ◦ f = ιA and f ◦ g = ιB.It is important that both g ◦ f = ιA and f ◦ g = ιB hold. To see that,take A = {1, 2} and B = {w, y, z}, and let f = {(1, w), (2, z)} and g ={(w, 1), (y, 1), (z, 2)}. Then g ◦ f = ιA. But f and g are not inverses: g mapsy to 1 but f maps 1 to w. That is, f ◦ g 6= ιA.

Page 14: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

14 CHAPTER 6. FUNCTIONS AND RELATIONS

When does a function f : A → B have an inverse, g? If g exists, then(remembering the definition of f as a set of ordered pairs) by the definitionof inverses it must be that g = {(b, a) : (a, b) ∈ f}. For this to be a function,there must be exactly one ordered pair with first component b for each b ∈ B.Therefore, f must map exactly one element of A to each element of B. Since“exactly one” implies “at most one”, f must be 1-1. And since “exactlyone” implies “at least one”, f must be onto. We have just proved half of thetheorem that characterizes (completely describes) the functions that have aninverse.

Theorem 6.7.1 A function f : A → B has an inverse g : B → A if andonly if it is 1-1 and onto.

Proof. We have already seen (above) that if f has an inverse, then f is 1-1and onto. It remains to prove the converse implication. Suppose f is 1-1and onto. Then every element of B is the image of exactly one element ofA (at most one because f is 1-1, and at least one because f is onto). Henceg = (b, a) : (a, b) ∈ f} is a function. By the definition of inverses, it is theinverse of f . �

It follows from the definition that if g is the inverse of f , then f is theinverse of g. Hence g is also 1-1 and onto.

The inverse of a function f : A → B is commonly denoted by f−1. It isa function with domain B and target A. (Remember that the inverse hereis with respect to function composition, so this is neither the negative off nor the reciprocal of f .) Since the inverse of the inverse is the originalfunction (that is, if the inverse of f is g, then the inverse of g is f), we have(f−1)−1 = f . Further, f−1 ◦ f = ιA and f ◦ f−1 = ιB.

We conclude this section by describing what happens when a function isa composition of 1-1 and onto functions.

Proposition 6.7.2 Suppose f : A → B and g : B → C are both 1-1 andonto. Then g ◦ f is 1-1 and onto.

Proof. We first show that g ◦ f is 1-1. Suppose g ◦ f(a1) = g ◦ f(a2). Theng(f(a1)) = g(f(a2)). Since f(a1) and f(a2) are elements of B and g is 1-1,f(a1) = f(a2). Now, since f 1-1, a1 = a2. Therefore, g ◦ f is 1-1.

Page 15: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.8. RELATIONS 15

We now show that g ◦ f is onto. Take any c ∈ C. Since g is onto, thereexists b ∈ B such that g(b) = c. Since f is onto, there exists a ∈ A such thatf(a) = b. For this a we have g ◦ f(a) = g(f(a)) = g(b) = c. Therefore, g ◦ fis onto. �

It is natural to wonder if the converse of the previous proposition holds.That is, if g◦f is 1-1 and onto, must both f and g be 1-1 and onto. Certainlyg must be onto: an element which is not in the range of g can not be in therange of g ◦ f . Similarly, f must be 1-1: if there exist different elementsa1, a2 ∈ A such that f(a1) = f(a2), then g ◦ f(a1) = g ◦ f(a2). There isno reason for f to be onto, however. All that’s needed for the the functionobtained from g by restricting the domain (of g) to the range of f (replacingB by rng f) to be onto. Similarly, there is no reason for g to be 1-1. What’sneeded is that if g maps several elements of B to the same element of C, thenonly one of these elements of B is in the range of f . We have shown is ifg ◦ f is 1-1 and onto, then f is 1-1 and g is onto. We leave it as an exerciseto follow the comments above and construct an explicit example where g ◦ fis 1-1 and onto, but f is not onto and g is not 1-1.

6.8 Relations

Suppose A is the set of all students registered at UVic this term, and B isthe set of all courses offered at UVic this term. Then A×B is the set of allordered pairs (s, c), where s is a student registered at UVic this term, and cis a course offered at UVic this term. The set A× B represents all possibleregistrations by a current student in a current course. Certain subsets ofA × B may be of interest, for example the subset consisting of the pairswhere the course is in Science and the student is actually registered in thecourse, or the subset consisting of the pairs where completion of the coursewould make the student eligible to receive a degree from the Faculty of FineArts. The idea is that relationships between the elements of A and theelements of B can be represented by subsets of A×B.

A binary relation from a set A to a set B is a subset R ⊆ A × B. Abinary relation on a set A is a subset of R ⊆ A× A.

The word “binary” arises because the relation contains pairs of objects.Ternary relations (on A, say) would contain triples of elements, quaternary

Page 16: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

16 CHAPTER 6. FUNCTIONS AND RELATIONS

relations would contain quadruples of elements, and in general n-are relationswould contain ordered n-tuples of elements. We will only consider binary re-lations, so we will drop the adjective “binary”. When we talk about relations,we mean binary relations. We will focus almost exclusively on relations on aset A.

A relation may or may not express a particular type of relationship be-tween its elements. The definition says that a relation is simply a subset.Any subset. It could be that the only relationship between x and y is thatthe pair (x, y) belongs to the subset. Subsets like R1 = ∅ and R2 = A × Aare perfectly good relations on A.

On the other hand, familiar things can be seen as relations. As a sample:

• Equality between integers is represented by the relation R on Z where(x, y) ∈ R if and only if x = y.

• Strict inequality between real numbers is represented by the relation Son R where (x, y) ∈ S if and only if x > y.

• The property of being a subset is represented by the relation C on P(U)where (X, Y ) ∈ C if and only if X ⊆ Y .

• Logical implication between statements p and q is represented by therelation I on the set of all statements (say involving a certain set ofBoolean variables) where (p, q) ∈ I if and only if p⇒ q.

Because of these examples, and many others like them involving commonmathematical symbols (that express particular relationships), infix notationis used: sometimes we write xRy instead of (x, y) ∈ R, and say that x isrelated to y (under R).

6.9 Properties of Relations

The relation “=” on the set of real numbers has the following properties:

• Every number is equal to itself.

• If x is equal to y, then y is equal to x.

Page 17: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.9. PROPERTIES OF RELATIONS 17

• Numbers that are equal to the same number are equal to each other.That is, if x = y and y = z, then x = z.

The relation “⇔” on the set of all propositions (in a finite number of vari-ables) has properties that look strongly similar to these.

• Every proposition is logically equivalent to itself.

• If p is logically to q, then q is logically equivalent to p.

• Propositions that are logically equivalent to the same proposition arelogically equivalent to each other to each other. That is, if p ⇔ q andq ⇔ r, then p⇔ r.

Similarly, the relation “≤” on the set of real numbers has the followingproperties:

• x ≤ x for every x ∈ R.

• If x ≤ y and y ≤ x, then x = y.

• If x ≤ y and y ≤ z, then x ≤ z.

The relation “⊆” on the the power set of a set S has similar properties:

• X ⊆ X for every X ∈ P(S).

• If X ⊆ Y and Y ⊆ X, then X = Y .

• If X ⊆ Y and Y ⊆ Z, then X ⊆ Z.

The relation “⇒” on the set of all propositions (in a finite number ofvariables) looks to have the same properties as the previous two, so long aswe accept “⇔” playing the role of “=”. There is, however, something subtleand beyond the scope of this discussion, going on in the second bullet pointbecause we use “⇔” instead of “=”.

• p⇒ p for every proposition x.

• If p⇒ q and q ⇒ p, then p⇔ q.

Page 18: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

18 CHAPTER 6. FUNCTIONS AND RELATIONS

• If p⇒ q and q ⇒ r, then p⇒ r.

It may or may not be clear that the first bullet point in each of the fivecollections describes the same abstract property. And the same for the thirdbullet point. The middle bullet point describes the same abstract propertyin the first two collections and in the first two of the last three, but thesetwo properties are fundamentally different.

• The first property in the five collections above is “reflexivity”. Thedictionary defines “reflexive” as meaning “directed back on itself”. Ina relation, we interpret that as meaning every element is related toitself. Thus, each of the relations described above is reflexive.

• The second property in the first two collections, but not the last three,is “symmetry”: if x is related to y, then y is related to x.

• The third property in all five collections is “transitivity”: if x is relatedto y, and y is related to z, then x is related to z.

• The second property in collection three and four is “anti-symmetry”:if x is related to y and y is related to x, then x is the same as y. Later,we will see that being anti-symmetric is very different from being notsymmetric. We will also get a hint of the origin of the (unfortunate)term “anti-symmetric”.

Formal definitions of these properties follow. It is important to realize thateach of these is a property that a particular relation might, or might not,have.

A relation R on a set A is:

• reflexive if (x, x) ∈ R for every x ∈ A. (Written in infix notation, thecondition is xRx for every x ∈ A.)

• symmetric if (y, x) ∈ R whenever (x, y) ∈ R, for all x, y ∈ A. (Writtenin infix notation, the condition is if xRy then yRx , for all x, y ∈ A.)

• transitive if (x, z) ∈ R whenever (x, y), (y, z) ∈ R, for all x, y, z ∈ A.(Written in infix notation, the condition is if xRy and yRz, then xRz, for all x, y, z ∈ A.)

Page 19: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.9. PROPERTIES OF RELATIONS 19

• anti-symmetric if x = y whenever (x, y) ∈ R and (y, x) ∈ R, for allx, y ∈ A. (Written in infix notation, the condition is if xRy and yRx,then x = y, for all x, y ∈ A.)

Why are we doing this? Relations that are reflexive, symmetric and transitivebehave a lot like “equals”: they partition the set A into disjoint collections ofelements that are “the same” (equivalent) with respect to whatever propertyis used to define the relation. These are called equivalence relations. Rela-tions that are that reflexive, anti-symmetric and transitive behave a lot like“less than or equal to” in the sense that they imply an ordering of some ofthe elements of A. To interpret this for the subset relation, think of X ⊆ Yas reading “X precedes or equals Y ” (there are some pairs of sets for whichneither “precedes or equals” the other). These are called partial orders.

What follows are six examples of determining whether or not a relationhas the properties defined above.

Consider the relation R1 = {(1, 1), (2, 2), (3, 3), (1, 2), (2, 1), (2, 3)} on theset A = {1, 2, 3}.

• R1 is reflexive: A = {1, 2, 3} and (1, 1), (2, 2), (3, 3) ∈ R1.

• R1 is not symmetric: (2, 3) ∈ R1 but (3, 2) 6∈ R1.

• R1 is not anti-symmetric: (1, 2), (2, 1) ∈ R1 but 1 6= 2.

• R1 is not transitive: (1, 2), (2, 3) ∈ R1 but (1, 3) 6∈ R1.

The definition says that a relation is symmetric if, whenever a pair (x, y)is in the relation, so is its “reversal” (y, x)”. This means that when x 6= y,either both of (x, y) and (y, x) are in the relation, or neither are.

The definition says that a relation is anti-symmetric if, when x 6= y, wenever have both of (x, y) and (y, x) in the relation. (The definition is phrasedin a way that makes it easy to use in proofs.) This means that x 6= y, either(x, y) is in the relation and (y, x) is not in it, or (y, x) is in the relationand (x, y) is not in it, or neither pair is in it. The only possibility that isnot permitted to arise in an anti-symmetric relation is for it to contain both(x, y) and (y, x), where x 6= y. (There is no pair of different elements whichare related in a symmetric way.)

Page 20: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

20 CHAPTER 6. FUNCTIONS AND RELATIONS

It is possible for a relation to be both symmetric and anti-symmetric,for example A = {(1, 1), (2, 2)} on the set {1, 2, 3}. The relation R1 aboveshows that it is also possible for a relation to be neither symmetric nor anti-symmetric.

Consider the relation R2 = ∅ on any non-empty set A.

• R2 is not reflexive. Since A 6= ∅, there exists x ∈ A. The ordered pair(x, x) 6∈ R2.

• R2 is symmetric. The implication if (x, y) ∈ R2, then (y, x) ∈ R2 istrue because its hypothesis is always false.

• R2 is anti-symmetric. The implication if (x, y), (y, x) ∈ R2, then x = yis true because its hypothesis is always false.

• R2 is transitive. The implication if (x, y), (y, z) ∈ R2, then (x, z) ∈ R2

is true because its hypothesis is always false.

If A = ∅, then what above changes slightly because R2 is reflexive. Can youexplain why?

Let R3 be the subset relation on P(S), the set of all subsets of S ={1, 2, 3, 4}, that is, (X, Y ) ∈ R3 if and only X ⊆ Y .

• R3 is reflexive because X ⊆ X for every X ⊆ S (for every X ∈ P(S)).

• R2 is not symmetric: (∅, {1}) ∈ R3 because ∅ ⊆ {1} but ({1}, ∅) 6∈ R3

because {1} 6⊆ ∅.

• R3 is anti-symmetric. Suppose (X, Y ), (Y,X) ∈ R3. Then X ⊆ Y andY ⊆ X. We proved before that this means X = Y .

• R3 is transitive. Suppose (X, Y ), (Y, Z) ∈ R3. Then X ⊆ Y andY ⊆ Z. We proved before that this means X ⊆ Z, that is (X,Z) ∈ R3.

If S = ∅, then what above changes slightly because R3 is symmetric. Canyou explain why?

Let R4 be the relation on N defined by (m,n) ∈ R4 if and only if m− nis even.

Page 21: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.9. PROPERTIES OF RELATIONS 21

• R4 is reflexive. Let k ∈ N. Then k−k = 0. Since 0 is even, (k, k) ∈ R4.

• R4 is symmetric. Suppose (m,n) ∈ R4. Then m − n is even. Sincen − m = −(m − n), and the negative of an even number is even,(n,m) ∈ R4.

• R4 not anti-symmetric: (1, 3), (3, 1) ∈ R4 but 1 6= 3.

• R4 is transitive. Suppose (k,m), (m,n) ∈ R4. Then k−m is even, andm − n is even. Hence, (k −m) + (m − n) = k − n is even – it is thesum of two even numbers. Therefore (k, n) ∈ R4.

Let A be a set with at least two elements, and let R5 be the relationA× A on A.

• R5 is reflexive. It contains all possible ordered pairs of elements of A,so it contains (x, x) for every x ∈ A.

• R5 is symmetric. It contains all possible ordered pairs of elements ofA, so it contains (y, x) whenever it contains (x, y).

• R5 not anti-symmetric: since A has at least two elements, there exista, b ∈ A such that a 6= b. Since (a, b), (b, a) ∈ A × A, the statementfollows.

• R5 is transitive. It contains all possible ordered pairs of elements of A,so it contains (x, z) whenever it contains (x, y) and (y, z).

If A has at most one element, then the above changes. In that case, R5 isanti-symmetric. Can you explain why?

Finally, let R6 be the relation on Z × Z defined by (a, b)R6(c, d) if andonly if a ≤ c and b ≤ d. Notice that, here, it is pairs of elements thatare being related (to each other) under R6, so technically R6 is an set ofordered pairs, of which the components are ordered pairs. The infix notation(a, b)R6(c, d) is far less cumbersome that writing ((a, b), (c, d)) ∈ R6.

• R6 is reflexive. Let (a, b) ∈ Z × Z. Since a ≤ a and b ≤ b, we have(a, b)R6(a, b).

• R6 is not symmetric: (1, 2)R6(3, 4) but (3, 4)R6(1, 2).

Page 22: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

22 CHAPTER 6. FUNCTIONS AND RELATIONS

• R6 is anti-symmetric. Suppose (a, b)R6(c, d) and (c, d)R6(a, b). Thena ≤ c and b ≤ d, and c ≤ a and d ≤ b. Therefore a = c and b = d, sothat (a, b) = (c, d).

• R6 is transitive. Suppose (a, b)R6(c, d) and (c, d)R6(e, f). We want(a, b)R6(e, f). Since (a, b)R6(c, d), a ≤ c and b ≤ d. Since (c, d)R6(e, f),c ≤ e and d ≤ f . Therefore a ≤ e and b ≤ f , so that (a, b)R6(e, f).

We close this section with a different sort of example. Suppose R is arelation on {1, 2, 3, 4} that is symmetric and transitive. Suppose also that(1, 2), (2, 3), (1, 4) ∈ R. What else must be in R?

• Since R is symmetric, we must have (2, 1), (3, 2), (4, 1) ∈ R.

• Since R is transitive and (1, 2), (2, 1) ∈ R, we must have (1, 1) ∈ R.Similarly (2, 2), (3, 3), (4, 4) ∈ R.

• Since (1, 2), (2, 3) ∈ R, transitivity implies (1, 3) ∈ R. Symmetry gives(3, 1) ∈ R.

Let’s summarize what we have done so far in an array. The rows and columnsare indexed by {1, 2, 3, 4}, and the entry in row i and column j is the truthvalue of the statement (i, j) ∈ R (that is, it is 1 if the pair (i, j) ∈ R and 0otherwise.

1 1 1 11 1 1 01 1 1 01 0 0 1

Notice that the array is symmetric (in the matrix-theoretic sense): the (i, j)-entry equals the (j, i)-entry. Must (2, 4) be in R? We have (2, 1), (1, 4) ∈ R,so (2, 4) ∈ R. Thus (4, 2) ∈ R by symmetry. What about (3, 4)? Wehave (3, 1), (1, 4) ∈ R, so again the answer is (3, 4) ∈ R. Thus (4, 3) ∈ R.Therefore R = A× A.

An array of the type in the previous example – rows and columns indexedby elements of A and (i, j)-entry the truth value of the statement (i, j) ∈ R– denotes a

• reflexive relation when every entry on the main diagonal equals 1;

Page 23: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.10. EQUIVALENCE RELATIONS 23

• symmetric relation when it is symmetric about the main diagonal: the(i, j)-entry equals the (j, i)-entry.

• anti-symmetric relation when there is no i 6= j such that the (i, j)-entryand the (j, i)-entry are both equal to 1. (Entries on the main diagonaldon’t matter, and it acceptable for the (i, j)-entry and the (j, i)-entryto both equal 0.)

It is not easily possible to look at the array and see if the relation is transitive.All of the possibilities need to be checked.

6.10 Equivalence Relations

An equivalence relation on a set A is a relation on A that is

• reflexive;

• symmetric; and

• transitive

Relations with these three properties are similar to “=”. Suppose R isan equivalence relation on A. Instead of saying “(x, y) ∈ R” or “x is relatedto y under R”, for the sake of this discussion let’s say “x is the same asy”. The reflexive property then says everything in A is the same as itself.The symmetric property says if x is the same as y, then y is the same as x.And the transitive property says things that are both the same as the sameelement are the same as each other. Another translation of these statementsarises from replacing “is the same as” by “is equivalent to”.

The following are examples of equivalence relations:

• logical equivalence on the set of all propositions;

• the relation R on Z defined by xRy if and only if x− y is even;

• the relation T on {0, 1, . . . , 24} defined by h1T h2 if any only if h1 hoursis the same time as h2 hours on a 12-hour clock;

Page 24: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

24 CHAPTER 6. FUNCTIONS AND RELATIONS

• the relation S on the set of all computer programs defined by p1Sp2 ifand only if p1 computes the same function at p2;

• the relation E on the set of all algebraic expressions in x defined byp(x) E q(x) if and only if p(x) = q(x) for every real number x. Forexample, if p(x) = x2 − 1 and q(x) = (x+ 1)(x− 1), then p(x) E q(x).

It is a useful exercise to prove that each of these is an equivalence relation.

Every equivalence relation “carves up” (mathematicians would say “parti-tions”) the underlying set into collections (sets) of “equivalent” things (thingsthat are “the same”), where the meaning of “equivalent” depends on the def-inition of the relation. In the examples above:

• logical equivalence partitions the universe of all statements into collec-tions of statements that mean the same thing, and hence can be freelysubstituted for each other;

• R partitions the integers into the even integers and the odd integers;

• T partitions {0, 1, . . . , 24} into collections of hours that represent thesame time on a 12-hour clock;

• S partitions the set of all computer programs into collections that dothe same thing;

• E partitions the set of all algebraic expressions into collections that givethe same numerical value for every real number x, and hence can befreely substituted for each other when manipulating equations.

Each of these collections of “equivalent” things is an example of what is calledan “equivalence class”.

Let R be an equivalence relation on A, and x ∈ A. The equivalence classof x is the set [x] = {y : yRx}.

Let A be a set. A partition of A is a collection of disjoint, non-emptysubsets whose union is A. That is, it is a set of subsets of A such that

• the empty set is not in the collection; and

• every element of A belongs to exactly one set in the collection.

Page 25: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.10. EQUIVALENCE RELATIONS 25

Each set in the collection is called a cell, or block, or element of the partition.

For example, if A = {a, b, c, d, e}, then the following are all partitions ofA:

• {{a}, {b, e}, {c, d}};

• {A};

• {{a, c, e}, {b, d}};

• {{a}, {b}, {c}, {d}, {e}}.

None of the following are partitions of A:

• {{a}, {b, e}, {c, d}, ∅};

• {{a, c, e}, {d}};

• {{a}, {b}, {c}, {a, d}, {e}};

• {a}, {b}, {c}, {d}, {e}.

The last example of something that isn’t a partition is slippery. It isn’t a set,hence it can’t be a partition. But this is just a technicality – mathematiciansfrequently write partitions in this way. The point of this example was tomake sure you’re aware of what happens sometimes, and what is intended.

That equivalence relations and partitions are actually two sides of thesame coin is the main consequence of the two theorems below. The firsttheorem says that the collection of equivalence classes is a partition of A(which is consistent with what we observed above). The second theoremsays that for any possible partition of A there is an equivalence relation forwhich the subsets in the collection are exactly the equivalence classes.

Theorem 6.10.1 Let R be an equivalence relation on A. Then

1. x ∈ [x];

2. if xRy then [x] = [y]; and

3. if x is not related to y under R, then [x] ∩ [y] = ∅.

Page 26: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

26 CHAPTER 6. FUNCTIONS AND RELATIONS

Proof. The first statement follows because R is reflexive.

To see the second statement, suppose xRy. If z ∈ [x] then (by definitionof equivalence classes) zRx. By transitivity, zRy. That is z ∈ [y]. Therefore[x] ⊆ [y]. A similar argument proves that [y] ⊆ [x], so that [x] = [y].

To see the third statement, we proceed by contradiction. Suppose x isnot related to y under R, but [x] ∩ [y] 6= ∅. Let z ∈ [x] ∩ [y]. Then zRx andzRy. By symmetry, xRz. And then by transitivity, xRy, a contradiction.Therefore, [x] ∩ [y] = ∅. �

Part 1 of the above theorem says that the equivalence classes are all non-empty, and parts 2 and 3 together say that every element of X belongs toexactly one equivalence class. Parts 2 and 3 also tell you how to determineif two equivalence classes are the same: [x] = [y] if and only if x is related toy (equivalently, since R is symmetric, y is related to x).

For example, suppose R is the relation on R defined by xRy if and only ifx rounds to the same integer as y. ThenR is an equivalence relation (exercise:prove it). The partition of R induced by R is {[n − 0.5, n + 0.5) : n ∈ Z},where each half-open interval [n−0.5, n+ 0.5) = {x : n+ 0.5 ≤ x < n+ 0.5}.Among [1], [

√2], [√

3], [2], [e], [π] there are exactly three different equivalenceclasses because [1] = [

√2]; [√

3] = [2], and [e] = [π].

Theorem 6.10.2 Let Π = {X1, X2, . . . , Xt} be a partition of a set A. Then

• the relation R on A defined by xRy if and only if x belongs to the samecell of Π as y is an equivalence relation; and

• Π is the partition of A induced by the set of equivalence classes of R.

Proof. The argument that shows R is an equivalence relation is left asan exercise.

We argue that Π is the partition of A induced by the set of equivalenceclasses of R. That is, it must be shown that, for any x ∈ A, the equivalenceclass of x equals the cell of the partition that contains x.

Take any x ∈ A, and suppose x ∈ Xi. We need to show that [x] = Xi.On the one hand, if y ∈ Xi then yRx by definition of R. Hence, y ∈ [x].Therefore, Xi ⊆ [x]. On the other hand, if y ∈ [x] then yRx. By definition

Page 27: Chapter 6 Functions and RelationsChapter 6 Functions and Relations 6.1 Cartesian Products In the Cartesian plane (or x-yplane), we associate the set of points in the plane with the

6.10. EQUIVALENCE RELATIONS 27

of R, the element y belongs to the same cell of Π as x. That is, y ∈ Xi.Therefore [x] ⊆ Xi. It now follows that [x] = Xi. �

For example, suppose we want an equivalence relation F on [0,∞) forwhich the partition of R induced by F is {[n, n+1) : n ∈ N∪{0}}. Accordingto the theorem statement, we define xFy if and only if there exists n ∈ N∪{0}such that x, y ∈ [n, n + 1). Looking at the definition of F we see that xFyif and only if the integer part of x (the part before the decimal point) isthe same as the integer part of y, or equivalently that the greatest integerless than or equal to x (commonly known as the floor of x and denotedbxc) is the same as the greatest integer less than or equal to y. In symbolsxFy ⇔ bxc = byc.