Lecture 2: functions and cardinality Just a note from last time. If we have an equivalence relation R on a set A, it is standard notation to write R/A = {[a]R : a ∈ A} for the set of equivalence classes of A under R. This is known as taking the quotient by an equivalence relation. At times the relation R is written in an implied manner using a symbol like ∼. For instance, (a, b) ∈ R would be written a ∼ b. In this case, the quotient is R/ ∼. Functions We will spend much of the course talking about functions, which are special kinds of relations. Definition 0.1. Let A and B be sets and f a relation between A and B. We say that f is a (well-defined) function from A to B, written f : A → B if the following hold. 1. For each a ∈ A, there is at least one b ∈ B such that (a, b) ∈ f . 2. For each a ∈ A, there is at most one b ∈ B such that (a, b) ∈ f . That is, if we ever have (a, b1 ) ∈ f and (a, b2 ) ∈ f for b1 , b2 ∈ B, it follows that b1 = b2 . The set A is called the domain of f and the B is called the codomain of f . Of course we will not continue to use this notation for a function, but the more familiar notation: if (a, b) ∈ f then because of item 2 above, we can unambiguously write f (a) = b. We will be interested in certain types of functions. Definition 0.2. The function f : A → B is called one-to-one (injective) if whenever a1 = 6 a2 then f (a1 ) 6= f (a2 ). It is called onto (surjective) if for each b ∈ B there exists a ∈ A such that f (a) = b. Another way to define onto is to first define the range of a function f : A → B by f (A) = {f (a) : a ∈ A} and say that f is onto if f (A) = B. Many times we want to compose functions to build other ones. Suppose that f : A → B and g : B → C are functions. Then (g ◦ f ) : A → C is defined as (g ◦ f )(a) = g((f (a)) . Formally speaking we define g ◦ f ⊆ A × C by (a, c) ∈ g ◦ f if (a, b) ∈ f and (b, c) ∈ g for some b ∈ B . Exercise: prove if f and g are functions as above, so is g ◦ f . 1 Proposition 0.3. Let f : A → B and g : B → C be functions. 1. If f and g are one-to-one then so is g ◦ f . 2. If f and g are onto then so is g ◦ f . Proof. We start with the first statement. Suppose that f and g are one-to-one; we will show that g ◦ f must be one-to-one. Suppose then that a and a0 in A are such that (g ◦ f )(a) = (g ◦ f )(a0 ). Then by definition, g(f (a)) = g(f (a0 )). But g is one-to-one, so f (a) = f (a0 ). Now since f is one-to-one, we find a = a0 . This shows that if (g ◦ f )(a) = (g ◦ f )(a0 ) then a = a0 , proving g ◦ f is one-to-one. Suppose then that f and g are onto. To show that g ◦ f is onto we must show that for each c ∈ C there exists a ∈ A such that (g ◦ f )(a) = c.This is the same statement as g(f (a)) = c. We know that g is onto, so there exists b ∈ B such that g(b) = c. Furthermore, f is onto, so for this specific b, there exists a ∈ A such that f (a) = b. Putting these together, (g ◦ f )(a) = g(f (a)) = g(b) = c . This completes the proof. If a function is both one-to-one and onto we can define an inverse function. Definition 0.4. If f : A → B is both one-to-one and onto we call f a bijection. Theorem 0.5. Let f : A → B. There exists a function f −1 : B → A such that f −1 ◦ f = idA and f ◦ f −1 = idB , (1) where idA : A → A and idB : B → B are the identity functions idA (a) = a and idB (b) = b if and only if f is a bijection. The meaning of the above equations is f −1 (f (a)) = a and f (f −1 (b)) = b for all a ∈ A and b ∈ B. Proof. Suppose that f : A → B is a bijection. Then define f −1 ⊆ B × A by f −1 = {(b, a) : (a, b) ∈ f } . This is clearly a relation. We claim it is a function. To show this we must prove that • for all b ∈ B there exists a ∈ A such that (b, a) ∈ f −1 and • for all b ∈ B there exists at most one a ∈ A such that (b, a) ∈ f −1 . Restated, these are • for all b ∈ B there exists a ∈ A such that f (a) = b and 2 • for all b ∈ B there exists at most one a ∈ A such that f (a) = b. These are exactly the conditions that f be a bijection, so f −1 is a function. Now we must show that f −1 ◦ f = idA and f ◦ f −1 = idB . We show only the first; the second is an exercise. For each a ∈ A, there is a b ∈ B such that f (a) = b. By definition of f −1 , we then have (b, a) ∈ f −1 ; that is, f −1 (b) = a. Therefore (a, b) ∈ f and (b, a) ∈ f −1 , giving (a, a) ∈ f −1 ◦ f , or (f −1 ◦ f )(a) = a = idA (a) . We have now shown that if f is a bijection then there is a function f −1 that satisfies (1). For the other direction, suppose that f : A → B is a function and g : B → A is a function such that g ◦ f = idA and f ◦ g = idB . We must show then that f is a bijection. To show one-to-one, suppose that f (a1 ) = f (a2 ). Then a1 = idA (a1 ) = g(f (a1 )) = g(f (a2 )) = idA (a2 ) = a2 ., giving that f is one-to-one. To show onto, let b ∈ B; we claim that f maps the element g(b) to b. To see this, compute b = idB (b) = f (g(b)). This shows that f is onto and completes the proof. Here are some more facts about inverses and injectivity/surjectivity. • If f : A → B is a bijection then so is f −1 : B → A. • If f : A → B and g : B → C are bijections then so is g ◦ f . • The identity map idA : A → A is a bijection. Cardinality This allows us to define an equivalence relation on sets: Definition 0.6. If A and B are sets, we say that A and B are equivalent (A ' B or A and B have the same cardinality) if there exists a bijection f : A → B. The cardinality of a set A (written ](A)) is defined as the equivalence class of A under this relation. That is ](A) = {B : A ' B} . 3