Chapter 2 Sets, Functions and Relations A set is any collection of distinct objects. Here is some notation for some special sets of numbers: Z denotes the set of integers (whole numbers), that is, Z = {0, 1, 1, 2, 2,...} ; N denotes the set of positive integers, that is, N = {1, 2, 3,...} ; Q denotes the set of rational numbers, that is the set of numbers which can be expressed in the form m n, where m, n are integers and n 0 ; R denotes the set of real numbers ; and C denotes the set of all complex numbers, that is, numbers of the form x + iy, where x, y are real. Notation x X means that x is an element of the set X (and x X means that x is not an element of the set X). Write A B to mean that A is a subset of B, that is, every element of A is an element of B. Thus N Z Q R C. Suppose that X has only finitely many elements, for example suppose the elements of X are the numbers 2, 3, 5, 7, 9. Then we may write X = {2, 3, 5, 7, 9}. More generally we write X = {x 1, x 2,..., x n } (where n is some positive integer) to indicate that the elements of X are x 1, x 2,..., x n. We allow repeats, for example, {2, 3, 5, 3, 7} = {2, 3, 5, 7} and what is more we don t mind in which order the elements are listed, so {2, 3, 5, 7} = {5, 2, 7, 3}. We often specify a subset of some given set by some defining property, for example A = {x Z : x is even} (which can also be written A = {x Z x is even}). 1
Let A and B be subsets of a set X. Standard notations: A B = {x X : x A and x B} (intersection) A B = {x X : x A or x B} (union) X \ A = A = {x X : x / A} (complement) = (empty set) RESULTS (seen in the course Geometry I ) (i) The commutative law for : X Y = Y X for all sets X, Y. (ii) The associative law for :(X Y ) Z = X (Y Z) for all sets X, Y, Z. (iii) The commutative law for : X Y = Y X for all sets X, Y. (iv) The associative law for : (X Y ) Z = X (Y Z) for all sets X, Y, Z. (v) The distributive laws for and : For all sets X, Y, Z, X (Y Z) = (X Y ) (X Z) and X (Y Z) = (X Y ) (X Z). (vi) De Morgan s Laws: If X and Y are subsets of a set U then (X Y ) = X Y and (X Y ) = X Y. We can also do operations on more than two sets at a time. Given subsets A 1, A 2,..., A n of a set X we define A 1 A 2 A n to be the set of elements of X which lie in at least one of the sets A 1, A 2,... A n. We define A 1 A 2 A n to be the set of elements which lie in all of the sets A 1, A 2,... A n. Example Let X = Z and take A 1 = {2, 3, 5, 7}, A 2 = {3, 5, 7} and A 3 = {7, 11, 13} then A 1 A 2 A 3 = {7} and A 1 A 2 A 3 = {2, 3, 5, 7, 11, 13}. Products of Sets Suppose X, Y are sets. We write X Y for the set of all pairs (x, y), with x X and y Y. Thus X Y = {(x, y) x X, y Y }. Elements (x, y) and (x, y ) of X Y are equal if and only if we have both x = x and y = y. Example A = {1, 2, 3}, B = {6, 7, 8}. Then A B = {(1, 6), (1, 7), (1, 8), (2, 6), (2, 7), (2, 8), (3, 6), (3, 7), (3, 8)}. 2
For a finite set X we write X for the number of elements in X. This number is called the cardinality of the set X. For example the set X = {2, 3, 5} has cardinality X = 3. Lemma 2.1 If X, Y are finite sets then X Y = X. Y. If we have sets X 1, X 2,..., X n we write X 1 X 2 X n for the set of all sequences (x 1, x 2,..., x n ), with x 1 X 1, x 2 X 2,..., x n X n. The order is important : we have (x 1, x 2,..., x n ) = (x 1, x 2,..., x n) if and only if we have x 1 = x 1 and x 2 = x 2,..., and x n = x n. For example if X 1 = X 2 = X 3 = R then the elements (1, 4, 7), (4, 7, 1), (7, 1, 4), (7, 4, 1), (1, 7, 4), (4, 1, 7), of X 1 X 2 X 3 are all different. Remark Products of sets are an important construction. For example, starting with R we can construct the plane R R (usually written R 2 ), we can construct 3-space R R R (usually written R 3 ) etc. Paradoxes Most of the sets we deal with in this course will be subsets of some set of numbers (N, Q, Z, R,...) or else they will be products of such subsets etc. If we allow more general collections of objects, we can get into logical difficulties. For example Bertrand Russell (1872-1970) considered (in 1901) the set: S = {all sets which are not elements of themselves} Many sets lie in S (for example the set of all pianos is not itself a piano and therefore this set is an element of S). But Russell asked: Is S itself an element of S? If S is an element of S, then S must satisfy the defining property for S, that is to say S / S. But if S is not an element of S, then S S. So S S S / S. This is a modern version of the Ancient Greek paradox concerning Epimenides, from Crete, who is reputed to have said All Cretans are liars. The courses Logic I and Logic II will have more to say about such conundrums. Functions A function consists of two sets together with a rule which assigns an element of the second set to each element of the first set. If we call the sets S and T, a function f from S to T consists of the two sets S and T together with a rule which assigns an element f(s) T to each element s S. A function is also often called a map or a mapping. 3
Examples (i) S = T = Z, f(x) = 2x + 3. (ii) S = R, T = R, f(x) = sin x + 2 cos x. (iii) S = Z, T = Q, f(x) = x/2. (iv) f : R C, f(x) = x + i0 (this map f : R C is called the inclusion map). Definitions codomain of f : S T. Given a function f : S T the set S is called the domain and the set T is called the In example (i) the domain and codomain of f are both Z. In example (ii) the domain and codomain of f are both R. In example (iii) the domain of f is Z and the codomain is Q. In example (iv) the domain is R and the codomain is C. Functions f : S T and g : U V are equal if S = U and T = V and f(x) = g(x) for all x S (= U). For example consider the map f : Z R given by the formula f(x) = 2x 3 and the map g : Z Q given by the formula g(x) = 2x 3. The maps f and g are different (because the codomain of f is not equal to the codomain of g). Definition The image of a function f : S T is the subset {f(x) x S} of T. We write Im(f) for the image of f. We call f onto (or surjective) if Im(f) = T, i.e. if the image of f is the whole of the codomain of f. The condition for an element t of T to be in the image of f is that there is some element s S such that t = f(s). Thus f is onto if (and only if) for each t T there exists some element s S such that t = f(s). S T 3 f In this picture the function f is not onto, since there are elements t T which are not in the image of f. Examples 1. Is the function f : R R, given by f(x) = x 2, onto? Note that f(x) = x 2 0 for every x R, so that 1 is not in the image of f. Hence Im(f) R and so f is not onto. (In fact Im(f) = {y R y 0}.) 4
2. Is the function f : C C, given by the formula f(z) = z 2, onto? Let ω be any element of C and write ω in polar form ω = re iθ (with r real and r 0 and θ real). Then ω = ( re iθ/2 ) 2 = f(z), where z = re iθ/2. So every element ω C lies in the image of f and hence f is onto. 3. Consider f : Z Z given by { x/2, if x is even; f(x) = 3x + 1, if x is odd. Is f onto? Yes - as we now demonstrate. If y Z then y = f(2y), in particular y has the form f(x) for some x Z, so y Im(f). Hence every element of Z is in the image of f, so Im(f) = Z and f is onto. Notation Suppose that f : S T and g : T U are functions. (Note that the codomain of f is equal to the domain of g.) The composite function h : S U is the function defined by the formula h(x) = g(f(x)), for x S. We often denote the composite function by g f, but sometimes we just write gf. Lemma 2.2 Suppose that S, T, U are sets and f : S T, g : T U are functions. If f and g are onto then so is the composite g f. Definition We call a function f : S T a one to one (1 1) function (or an injective function) if for each pair of different elements s 1, s 2 of S the elements f(s 1 ), f(s 2 ) of T are distinct (i.e. different). There are various other ways of expressing this condition. One is that f is 1 1 if whenever f(s 1 ) = f(s 2 ), for elements s 1, s 2 S, then we necessarily have s 1 = s 2. In other words the condition f(s 1 ) = f(s 2 ) implies that s 1 = s 2. Another way of stating the 1 1 condition is that for each t T there exists at most one element s S mapping to t. Examples 1. Consider the function f : R R given by f(x) = x 2. We have f(1) = f( 1) so that different elements of R map to the same element under f, so f is not 1 1. 2. Consider the function f : R R given by f(x) = x. We claim that f is 1 1. We must check that f(x 1 ) = f(x 2 ) implies that x 1 = x 2. But if f(x 1 ) = f(x 2 ) then x 1 = x 2 giving x 1 = x 2, so f is 1 1. 3. f : N N given by { x/2, if x is even; f(x) = 3x + 1, if x is odd. 5
If we can t see the answer directly we can draw up a table to examine a few values to see if this will help us. 1 4 2 1 3 10 4 2 5 16 6 3 7 22 8 4 But now we can stop because we see that two distinct element map to the same element under f, i.e. f(1) = f(8) = 4 so that f is not 1 1. We now have the counterpart of Lemma 2.2 for the 1 1 property. Lemma 2.3 Suppose S, T, U are sets and f : S T, g : T U are maps. If f and g are both 1 1 then the composite g f is 1 1. Definition A map f : S T is called a bijection if it is 1 1 and onto. Definition Let f : S T be a map. A map g : T S such that g(f(s)) = s, for all s S, and f(g(t)) = t, for all t T, is called an inverse of f. One also says that f and g are inverse maps. Remark For any set X we have the map ι : X X given by ι(x) = x, for all x X. The map ι is called the identity map on X. Sometimes one writes ι X for this map, to stress that it is defined on the set X. The conditions for f and g to be inverse maps can now be expressed g f = ι S and f g = ι T. Example Let f : R R be given by f(x) = 2x + 3. Show that f has an inverse. We have to find a map g : R R which satisfies f(g(x)) = x (and g(f(x)) = x) for all x R. Now f(g(x)) = 2g(x) + 3 so we get 2g(x) + 3 = x and hence g(x) = (x 3)/2. So we define g : R R by the formula g(x) = (x 3)/2 and check that g is an inverse of f. Remark There is at most one inverse to a given map f : S T. Assume that g : T S is an inverse and that h : T S is too. Then we get h(t) = h(f(g(t))) = h(f(s)) (where s = g(t)) so that h(t) = h(f(s)) = s = g(t). So h(t) = g(t) for all t T and hence h = g. So from now on when an inverse g exists to a map f we call g the inverse of f. Proposition 2.4 A map f : S T is a bijection if and only if f has an inverse. 6
The Power Set Let X be a set. We write P (X) for the set whose elements are the subsets of X. The set P (X) is called the power set of X. Examples 1. Let X = {2, 3, 5}. Then P (X) is the set whose elements are, {2}, {3}, {5}, {2, 3}, {2, 5}, {3, 5}, {2, 3, 5}. In other words we have P (X) = {, {2}, {3}, {5}, {2, 3}, {2, 5}, {3, 5}, {2, 3, 5}}. 2. The power set P (C) has elements N,Z,Q,R (and lots more). 3. If X = {x} (X has one element) then P (X) = {, X}. Lemma 2.5 Suppose that X is a finite set and X = n. Then P (X) = 2 n. Relations Given a statement that applies to pairs of elements of a set X we say that x is related to y (and write x y) if this statement is true. Examples 1. Take X to be the set of all people and the statement to be x is the mother of y, so we write x y if x is the mother of y, for example we have Barbara Bush George W Bush Barbara Bush Jeb Bush. 2. Take X = Z and the relation to be x y is even. Then 1 3, 5 17, 2 8 but it is not true that 1 6. 3. Take X = R and the relation to be x is less than y, so 1 3, 2 5 etc. It is often useful to decide whether a relation on a set X has the following important properties. Reflexive Call reflexive if x x for every x X. Symmetric Call symmetric if whenever x y then y x. 7
Transitive Call transitive if whenever x y and y z then x z. Examples 1. Let X = Z and the relation x y if x y is even. Reflexive We have x x since x x = 0 which is even, for every x X, so is reflexive. Symmetric If x y then x y is even, hence y x (which is (x y)) is even and so y x. So the relation is reflexive. Transitive If x y and y z then x y and y z are even. Hence x z = (x y) + (y z) is even and x z. So if x y and y z then x z and so is a transitive relation. 2. Now take X to be the set of all people and x y if x is the mother of y. This relation fails all properties spectacularly. Reflexive - No. A person is not his or her own mother. Symmetric - No. If x is the mother of y then y is not the mother of x (in fact y is the son or daughter of x). Transitive - No. If x is the mother of y and y is the mother of z then x is not the mother of z (in fact x is the grandmother of z). 3. Take X = Z and x y meaning that 3 divides x + y. Reflexive - No. It is not true that 1 1 (3 does not divide 1 + 1 = 2). Symmetric - Yes. If x y then 3 divides x + y, so 3 divides y + x, so y x. Transitive - No. For example 1 2 and 2 4 but it is not true that 1 4. Definition A relation is called an equivalence relation if it is reflexive, symmetric and transitive. Example Let f : S T be any function. Let be the relation on S given by x y if f(x) = f(y). We check that is an equivalence relation. Reflexive - Yes. x x because f(x) = f(x). Symmetric - Yes. If x y then f(x) = f(y) so f(y) = f(x), in other words y x. Transitive - Yes. If x y and y z then f(x) = f(y) and f(y) = f(z) so that f(x) = f(z) and hence x z. Definition Let be an equivalence relation on a set X. For x X we define E x = {y X x y}. We call E x the equivalence class defined by x. 8
Example Take X = Z and x y if x y is even. If x is even the E x = {..., 4, 2, 0, 2, 4, 6,...} and if x is odd then E x = {..., 5, 3, 1, 1, 3, 5,...}. Notation Let f : S T be a map and let V be a subset of T. We define a subset f 1 V of S by f 1 V = {x S f(x) V }. Thus an element x of S belongs to f 1 V if and only if f(x) belongs to V. Example Let f : Z Z be the map f(x) = x. Let V be the set of non-negative integers. Then f 1 V is the set of all x Z such that f(x) = x is non-negative. Hence f 1 V is the set of all non-positive integers. Example Let f : S T be an onto map and let be the relation x y if f(x) = f(y). The sets E x defined above are exactly the subsets of S of the form f 1 {t}, for some t T. We prove this. Consider E x. Put t = f(x). If y E x then f(y) = f(x) = t, i.e. y f 1 {t}. This shows that E x f 1 {t}. Conversely if s S is any element of f 1 {t} then f(s) = t = f(x) so that x s and s E x. This shows that f 1 {t} E x and hence E x = f 1 {t}. So every E x has the claimed form. Now let t be any element of T and consider the set f 1 {t}. Pick x S such that f(x) = t (we can do this because f is onto). Then as above we get E x = f 1 {t} and so every set of the form f 1 {t} is equal to E x for some x S. This completes the proof. Definition Subsets A, B of a set X are called disjoint if A B =. Theorem 2.6 Let X be a set and let be an equivalence relation on X. Then: (i) x E x (for each x X). (ii) For x, y X the sets E x, E y are either equal or disjoint (i.e. either E x = E y or E x E y = ). (iii) E x = E y if and only if x y. Given an equivalence on a set X we often write [x] for the equivalence class E x of x, in other words [x] = {y X x y}. Example Let X = Z and fix a positive integer m. Define x y to mean that x y is a multiple of m (i.e. x y = mr for some r Z). Then is an equivalence relation. Here the equivalence class of any given element x Z is: [x] = {..., x 2m, x m, x, x + m, x + 2m,...}. For a concrete example take m = 4. In this case: [0] = all multiples of 4 = {..., 8, 4, 0, 4, 8,...} 9
[1] = all integers which have remainder 1 on division by 4 = {..., 7, 3, 1, 5, 9,...} [2] = {..., 2, 2, 6, 10,...} [3] = {..., 5, 1, 3, 7, 11,...} and every element of Z is in just one of these four equivalence classes (as asserted by Theorem 2.6(ii)). There is another way of viewing equivalence relations. Definition Let X be a set. A partition of X is a set P of non-empty subsets of X such that each element of X belongs to one and only one set in P. Note that P is a subset of P (X). Example Take X = {1, 2, 3, 4, 5}. (a) The subsets {1, 3}, {2, 4, 5} form a partition of X, in other words P = {{1, 3}, {2, 4, 5}} is a partition of X. (b) The subsets {1}, {5}, {2, 4, 3} form a partition of X, i.e. P = {{1}, {5}, {2, 4, 3}} is a partition of X. (c) The subsets {1, 4}, {2}, {3, 5} form a partition of X (i.e. P = {{1, 4}, {2}, {3, 5}} is a partition of X). (d) There are lots more! If there are n sets in the partition of X we can picture the partition as : X 1 X 2 X 4 X 3 X 5 Here n = 5. We can restate Theorem 2.6 as follows. 10
Theorem 2.7 Suppose that is an equivalence relation on X. Then the equivalence classes {E x x X} form a partition of X. On the other hand starting with a partition P of a set X we can make an equivalence relation by defining x y to mean that the elements x and y belong to the same set in this partition. The equivalence classes for this equivalence relation are then the sets which make up the partition P. This gives a correspondence between equivalence relations and partitions on a set X. Equivalence Relations and subsets of X X Since the idea of an equivalence relation is so important we give one more way of thinking about them. Suppose that is any relation (not necessarily an equivalence relation) on a set X. We define a subset R of X X by R = {(x, y) x y}. On the other hand if we start with a subset R of X X we then make a relation by defining x y if (x, y) R. We can now state the conditions for an equivalence relation in terms of the subset R of X X. Lemma 2.8 is an equivalence relation if and only if R has the following properties: (i) (x, x) R for all x X; (ii) whenever (x, y) R then (y, x) R; (iii) whenever (x, y) R and (y, z) R then (x, z) R. Example Suppose X = {2, 3, 5} and R = {(2, 2), (2, 3), (2, 5), (3, 3), (5, 5)}. The relation defined by R (that is x y if (x, y) R) is not an equivalence relation because (2, 3) R but (3, 2) is not in R (so that (ii) fails, and so symmetry fails for ). Graphs of functions The mathematical way to describe the graph of a function is as a subset of the product of the domain and codomain. Let f : S T be a map. Then the graph of f is the subset {(x, f(x)) x S} of S T. Even if S = T the graph of a function from S to T does not usually satisfy the properties listed in Lemma 2.8. In fact for any given domain S there is just one function f : S S which satisfies these properties. (Exercise: Which function is this?) Example Take S = T = R and f(x) = x 2. Then the graph of f is the set of points {(x, x 2 ) x R}, which we draw in the plane as the set of all points (x, y) having y = x 2. 11