Mascot image.
← MA0 1 · Introduction to University Mathematics (Proofs)

Lesson 4

Functions

Taught

More Sets

Once the axioms of set theory are in place, we can review some elementary albeit very useful constructions that these axioms enable.

Ordered Pairs

We often need to pair two elements while retaining their positions, and an ordinary two-element set cannot do this, since {a,b}={b,a}\{a, b\} = \{b, a\}; something more is needed if one element is to be marked as coming before the other. We could simply declare that the notation (a,b)(a, b) is ordered, but what does ordered mean in terms of sets?

Before choosing a set to represent (a,b)(a, b), we state the property any such choice must have: whenever (a,b)(a, b) and (c,d)(c, d) are ordered pairs,

(a,b)=(c,d)    (a=c)(b=d).()(a, b) = (c, d) \iff (a = c) \land (b = d). \tag{$*$}

In particular, the two coordinates must be recoverable from the pair.

Definition 4.1 (Ordered pair).

Let aa and bb be objects. The ordered pair (a,b)(a, b) is the set

(a,b)  =def  {{a},{a,b}},(a, b) \;\defeq\; \bigl\{\{a\}, \{a, b\}\bigr\},

where aa is its first coordinate and bb its second coordinate.

The sets used to encode the pair, {a}\{a\} and {a,b}\{a, b\}, are supplied by the pairing axiom of the last chapter, and the set on the right exists by that same axiom applied once more, to those two. The construction is due to Kuratowski. Does it satisfy ()(*)?

Proposition 4.2 (Equality of ordered pairs).

For objects aa, bb, cc and dd, (a,b)=(c,d)(a, b) = (c, d) if and only if a=ca = c and b=db = d.

Discussion.

Our statement is a biconditional. The reverse implication, a=ca = c and b=db = d implies (a,b)=(c,d)(a, b) = (c, d), is a direct substitution into the definition of the ordered pair. For the forward implication we assume {{a},{a,b}}={{c},{c,d}}\bigl\{\{a\}, \{a, b\}\bigr\} = \bigl\{\{c\}, \{c, d\}\bigr\} and must recover the coordinates from the set; the argument splits into the cases a=ba = b and aba \neq b, because in the first case the pair collapses to the singleton {{a}}\bigl\{\{a\}\bigr\} while in the second its two elements are distinct and can be chased through the equality one at a time. The logical proof avoids the split: it expands each ordered pair, rewrites set equality as the two inclusions by mutual inclusion, and lets the distributive and absorption laws of the first chapter reduce the resulting disjunctions to the conjunction a=cb=da = c \land b = d.

Proof (element style).

Let aa, bb, cc and dd be arbitrary objects. For the reverse implication, suppose a=ca = c and b=db = d. Then {a}={c}\{a\} = \{c\} and {a,b}={c,d}\{a, b\} = \{c, d\}; hence (a,b)={{a},{a,b}}={{c},{c,d}}=(c,d)(a, b) = \bigl\{\{a\}, \{a, b\}\bigr\} = \bigl\{\{c\}, \{c, d\}\bigr\} = (c, d).

For the forward implication, suppose (a,b)=(c,d)(a, b) = (c, d). By the definition of set equality, every element of either ordered pair belongs to the other; we divide the argument into two cases, a=ba = b and aba \neq b.

If a=ba = b, then (a,b)={{a},{a,a}}={{a}}(a, b) = \bigl\{\{a\}, \{a, a\}\bigr\} = \bigl\{\{a\}\bigr\}. Both {c}\{c\} and {c,d}\{c, d\} belong to (c,d)=(a,b)={{a}}(c, d) = (a, b) = \bigl\{\{a\}\bigr\}, so each must equal {a}\{a\}; hence c=ac = a and d=ad = a. Since b=ab = a as well, we obtain a=ca = c and b=db = d.

If aba \neq b, then {a}{a,b}\{a\} \neq \{a, b\}; consequently (a,b)(a, b) has two distinct elements. Since {a}(a,b)=(c,d)\{a\} \in (a, b) = (c, d), either {a}={c}\{a\} = \{c\} or {a}={c,d}\{a\} = \{c, d\}. The latter equality would give c=d=ac = d = a, so (c,d)={{a}}(c, d) = \bigl\{\{a\}\bigr\} would have only one element; this contradicts (a,b)=(c,d)(a, b) = (c, d), since (a,b)(a, b) has two. Therefore {a}={c}\{a\} = \{c\}, and hence a=ca = c.

Similarly, since {a,b}(a,b)=(c,d)\{a, b\} \in (a, b) = (c, d), either {a,b}={c}\{a, b\} = \{c\} or {a,b}={c,d}\{a, b\} = \{c, d\}. The former equality would give a=b=ca = b = c, contradicting aba \neq b; therefore {a,b}={c,d}\{a, b\} = \{c, d\}. It follows that b=cb = c or b=db = d; but c=abc = a \neq b, so bcb \neq c and hence b=db = d. Thus a=ca = c and b=db = d.

Remark.

This logical proof is dumb and covoluted lol but why not.

Proof (logical style).

Let aa, bb, cc and dd be arbitrary objects. By the definition of set equality,

(a,b)=(c,d)({{a},{a,b}}{{c},{c,d}})({{c},{c,d}}{{a},{a,b}})(({a}={c}{a}={c,d})({a,b}={c}{a,b}={c,d}))(({c}={a,b}{c}={a})({c,d}={a}{c,d}={a,b}))(({a}={c}{a}={c,d})({c}={a,b}{c}={a}))(({a,b}={c}{a,b}={c,d})({c,d}={a}{c,d}={a,b}))({a}={c}({a}={c,d}{a,b}={c}))({a,b}={c,d}({a,b}={c}{c,d}={a}))({a}={c,d}{a,b}={c})({a}={c}{a,b}={c,d})((a=ca=d)(a=cb=c))(a=c((a=cb=d)(a=db=c)))(a=ca=db=c)(a=cb=d)(a=ca=db=c)(a=ca=db=c)(a=cb=d)(a=ca=db=cb=d)(a=cb=d)a=cb=d.\begin{aligned} (a, b) = (c, d) &\equiv \Bigl(\bigl\{\{a\}, \{a, b\}\bigr\} \subset \bigl\{\{c\}, \{c, d\}\bigr\}\Bigr) \\ &\qquad {}\land \Bigl(\bigl\{\{c\}, \{c, d\}\bigr\} \subset \bigl\{\{a\}, \{a, b\}\bigr\}\Bigr) \\[2pt] &\equiv \Bigl(\bigl(\{a\} = \{c\} \lor \{a\} = \{c, d\}\bigr) \\ &\qquad\quad {}\land \bigl(\{a, b\} = \{c\} \lor \{a, b\} = \{c, d\}\bigr)\Bigr) \\ &\qquad {}\land \Bigl(\bigl(\{c\} = \{a, b\} \lor \{c\} = \{a\}\bigr) \\ &\qquad\qquad {}\land \bigl(\{c, d\} = \{a\} \lor \{c, d\} = \{a, b\}\bigr)\Bigr) \\[2pt] &\equiv \Bigl(\bigl(\{a\} = \{c\} \lor \{a\} = \{c, d\}\bigr) \\ &\qquad\quad {}\land \bigl(\{c\} = \{a, b\} \lor \{c\} = \{a\}\bigr)\Bigr) \\ &\qquad {}\land \Bigl(\bigl(\{a, b\} = \{c\} \lor \{a, b\} = \{c, d\}\bigr) \\ &\qquad\qquad {}\land \bigl(\{c, d\} = \{a\} \lor \{c, d\} = \{a, b\}\bigr)\Bigr) \\[2pt] &\equiv \Bigl(\{a\} = \{c\} \lor \bigl(\{a\} = \{c, d\} \land \{a, b\} = \{c\}\bigr)\Bigr) \\ &\qquad {}\land \Bigl(\{a, b\} = \{c, d\} \lor \bigl(\{a, b\} = \{c\} \land \{c, d\} = \{a\}\bigr)\Bigr) \\[2pt] &\equiv \bigl(\{a\} = \{c, d\} \land \{a, b\} = \{c\}\bigr) \\ &\qquad {}\lor \bigl(\{a\} = \{c\} \land \{a, b\} = \{c, d\}\bigr) \\[2pt] &\equiv \Bigl(\bigl(a = c \land a = d\bigr) \land \bigl(a = c \land b = c\bigr)\Bigr) \\ &\qquad {}\lor \Bigl(a = c \land \bigl((a = c \land b = d) \lor (a = d \land b = c)\bigr)\Bigr) \\[2pt] &\equiv (a = c \land a = d \land b = c) \lor (a = c \land b = d) \\ &\qquad {}\lor (a = c \land a = d \land b = c) \\[2pt] &\equiv (a = c \land a = d \land b = c) \lor (a = c \land b = d) \\[2pt] &\equiv (a = c \land a = d \land b = c \land b = d) \lor (a = c \land b = d) \\[2pt] &\equiv a = c \land b = d. \end{aligned}

Corollary 4.3 (Swapping coordinates).

For objects aa and bb, (a,b)=(b,a)(a, b) = (b, a) if and only if a=ba = b.

Proof.

If (a,b)=(b,a)(a, b) = (b, a), then Proposition 4.2 gives a=ba = b by comparing first coordinates. Conversely, if a=ba = b, then (a,b)=(a,a)=(b,a)(a, b) = (a, a) = (b, a).

Kuratowski’s is not the only set that will serve. A shorter candidate suggests itself, and the next problem asks what it costs.

Problem 4.1.

Some authors define the ordered pair by the shorter set

a,b  =def  {a,{a,b}}.\langle a, b \rangle \;\defeq\; \bigl\{a, \{a, b\}\bigr\}.
  1. Prove that this also satisfies ()(*), so that a,b=c,d\langle a, b \rangle = \langle c, d \rangle if and only if a=ca = c and b=db = d. You may use the axiom of regularity from the last chapter, and in particular the conclusion of its second problem.
  2. Show that regularity is genuinely needed, by identifying the step of your argument that fails without it, and say why the same step does not arise for Definition 4.1 .

Nesting ordered pairs builds longer ordered tuples.

Definition 4.4 (Ordered triples and longer).

Let aa, bb, cc and dd be objects. The ordered triple and ordered quadruple are

(a,b,c)  =def  ((a,b),c),(a,b,c,d)  =def  ((a,b,c),d),(a, b, c) \;\defeq\; \bigl((a, b), c\bigr), \qquad (a, b, c, d) \;\defeq\; \bigl((a, b, c), d\bigr),

and further tuples are assembled the same way.

Remark.

We have now overloaded the parenthesis symbols ( )(\ ) once again: they are used not only to group operators and arguments, but also to enclose ordered pairs. This is usually not a problem in practice, as one can still determine from context which usage is intended.

Cartesian Products

With ordered pairs in hand we can collect all of them at once. The collection has to come from somewhere, and the power set supplies it.

Proposition 4.5 (Where ordered pairs live).

Let AA and BB be sets, let aAa \in A and bBb \in B. Then (a,b)P(P(AB))(a, b) \in \mathcal{P}\bigl(\mathcal{P}(A \cup B)\bigr).

Discussion.

An ordered pair is a set of two sets, so it sits two power sets up from whatever holds its coordinates, and the set holding both coordinates is ABA \cup B. The work is to climb that ladder one rung at a time: show each of {a}\{a\} and {a,b}\{a, b\} is a subset of ABA \cup B, which puts both in P(AB)\mathcal{P}(A \cup B), and then that having both as elements makes (a,b)(a, b) a subset of P(AB)\mathcal{P}(A \cup B), which is what membership in the next power set asks for.

Proof.

Since aAa \in A we have aABa \in A \cup B, and since bBb \in B we have bABb \in A \cup B. Every element of {a}\{a\} is aa, and every element of {a,b}\{a, b\} is aa or bb, so both {a}AB\{a\} \subset A \cup B and {a,b}AB\{a, b\} \subset A \cup B, that is, both belong to P(AB)\mathcal{P}(A \cup B).

The elements of (a,b)={{a},{a,b}}(a, b) = \bigl\{\{a\}, \{a, b\}\bigr\} are exactly those two sets, so (a,b)P(AB)(a, b) \subset \mathcal{P}(A \cup B), which is (a,b)P(P(AB))(a, b) \in \mathcal{P}\bigl(\mathcal{P}(A \cup B)\bigr).

Definition 4.6 (Cartesian product).

Let AA and BB be sets. The Cartesian product A×BA \times B is the set of all ordered pairs with first coordinate in AA and second in BB,

A×B  =def  {pP(P(AB))    aA bB(p=(a,b))},A \times B \;\defeq\; \Bigl\{p \in \mathcal{P}\bigl(\mathcal{P}(A \cup B)\bigr) \;\Big|\; \exists a \in A\ \exists b \in B\,\bigl(p = (a, b)\bigr)\Bigr\},

so that for every object pp, pA×Bp \in A \times B exactly when p=(a,b)p = (a, b) for some aAa \in A and some bBb \in B.

The product needs no axiom of its own. The proposition above puts every candidate pair inside P(P(AB))\mathcal{P}(\mathcal{P}(A \cup B)), a set we are already holding, and comprehension carves the product out of it.

Example 4.7.

Let A={1,2}A = \{1, 2\} and B={r,s}B = \{r, s\}. Then A×B={(1,r),(1,s),(2,r),(2,s)}A \times B = \bigl\{(1, r), (1, s), (2, r), (2, s)\bigr\}. Order matters here in a way it did not for unordered pairs: (1,r)A×B(1, r) \in A \times B while (r,1)B×A(r, 1) \in B \times A, and the two products are different sets.

Problem 4.2.

Let AA and BB be sets. Show that A×B=A \times B = \emptyset if and only if A=A = \emptyset or B=B = \emptyset.

Membership in a product is a conjunction, which adds another line to the dictionary:

((s,t)S×T)(sS)(tT).\bigl((s, t) \in S \times T\bigr) \equiv (s \in S) \land (t \in T).

Example 4.8.

Order matters, and in general S×TT×SS \times T \neq T \times S. With S={1,2}S = \{1, 2\} and T={a,b,c}T = \{a, b, c\} we have T×S={(a,1),(a,2),(b,1),(b,2),(c,1),(c,2)}T \times S = \{(a, 1), (a, 2), (b, 1), (b, 2), (c, 1), (c, 2)\}, which is not the earlier set: the element (1,a)(1, a) lies in S×TS \times T but not in T×ST \times S, since 1T1 \notin T.

Example 4.9.

For any set SS, both S×S \times \emptyset and ×S\emptyset \times S are empty. A pair in S×S \times \emptyset would need its second coordinate from \emptyset, which has nothing to give; through the dictionary, ((s,t)S×)(sS)\bigl((s, t) \in S \times \emptyset\bigr) \equiv (s \in S) \land \bot \equiv \bot.

Products of three or more sets work the same way, S×T×RS \times T \times R collecting the triples (s,t,r)(s, t, r) with sSs \in S, tTt \in T and rRr \in R, and so on upwards. There is a wrinkle in that, and it is worth seeing before we lean on the notation.

Remark (Order of operations).

The definition takes two sets at a time, so for three sets there are two readings, and they are not the same set. Applying it twice, the elements of A×(B×C)A \times (B \times C) are the pairs (x,(y,z))\bigl(x, (y, z)\bigr), which unfold to

{{x}, {x,{{y},{y,z}}}},\bigl\{\{x\},\ \bigl\{x, \{\{y\}, \{y, z\}\}\bigr\}\bigr\},

while the elements of (A×B)×C(A \times B) \times C are the pairs ((x,y),z)\bigl((x, y), z\bigr), which unfold to

{{{{x},{x,y}}}, {{{x},{x,y}},z}}.\Bigl\{\bigl\{\{\{x\}, \{x, y\}\}\bigr\},\ \bigl\{\{\{x\}, \{x, y\}\}, z\bigr\}\Bigr\}.

Both should intuitively be the set of all triples (x,y,z)(x, y, z), and they do describe the same object once we identify them. Using a term we introduce below, the identification amounts to checking that

(x,(y,z))((x,y),z)\bigl(x, (y, z)\bigr) \longmapsto \bigl((x, y), z\bigr)

is a bijection from the first set onto the second, so the product is associative up to that correspondence. Once bijections are in hand this is a short piece of work, and the problems below ask you to do it; from then on we drop the brackets and write A×B×CA \times B \times C.

Problem 4.3.

We said that S×TT×SS \times T \neq T \times S in general. Find every case in which they are equal.

Indexed Families

A bag of sets is awkward to work with, since we keep having to point at its members. Giving each set a label fixes that: every member becomes addressable, and the labels do the organising from then on.

Definition 4.10 (Indexed family).

Let II be a set. An indexed family consists of one object xix_i for each iIi \in I, and is written {xi}iI\{x_i\}_{i \in I}. The set II is the index set and ii is an index. Different indices may label the same object.

Example 4.11.

Let AA, CC and DD be sets, take I={1,2,3,4}I = \{1, 2, 3, 4\}, and declare B1=defAB_1 \defeq A, B2=defCB_2 \defeq C, B3=defAB_3 \defeq A and B4=defDB_4 \defeq D. The family {Bi}iI\{B_i\}_{i \in I} has four entries, and the coincidence B1=B3B_1 = B_3 erases neither of them: the labels 11 and 33 know themselves apart even when the objects they carry do not. The braces in the notation are a convention, since what we are holding is an assignment of an object to each index, and that assignment remembers what the plain set of members, {A,C,D}\{A, C, D\}, has already forgotten.

Definition 4.12 (Indexed unions and intersections).

Let {Ai}iI\{A_i\}_{i \in I} be an indexed family of sets with II non-empty. Its union and intersection are

iIAi=def{Ai:iI},iIAi=def{xiIAi    iI(xAi)},\bigcup_{i \in I} A_i \defeq \bigcup \{A_i : i \in I\}, \qquad \bigcap_{i \in I} A_i \defeq \Bigl\{x \in \bigcup_{i \in I} A_i \;\Big|\; \forall i \in I\,(x \in A_i)\Bigr\},

so that xiIAix \in \bigcup_{i \in I} A_i exactly when xAix \in A_i for some iIi \in I, and xiIAix \in \bigcap_{i \in I} A_i exactly when xAix \in A_i for every iIi \in I.

Neither needs an axiom beyond those we have. Replacement turns the index set into the set {Ai:iI}\{A_i : i \in I\} of members, since each ii has exactly one partner AiA_i, and the union axiom pools what those members hold. The intersection is then carved out of that union by comprehension, exactly as the intersection of a system of sets was in the last chapter, and for the same reason: an object lying in every member lies in some member, so nothing is lost by looking only inside the union.

By the bounded quantifier convention of the last chapter, the two membership tests unabbreviate to i((iI)(xAi))\exists i\,\bigl((i \in I) \land (x \in A_i)\bigr) for the union and i((iI)    (xAi))\forall i\,\bigl((i \in I) \implies (x \in A_i)\bigr) for the intersection.

For I={1,2}I = \{1, 2\} the new symbols hand back the old ones, iIAi=A1A2\bigcup_{i \in I} A_i = A_1 \cup A_2 and iIAi=A1A2\bigcap_{i \in I} A_i = A_1 \cap A_2. With quantifiers doing the work, the negation rules settle what it takes not to belong:

xiIAi    iI(xAi),xiIAi    iI(xAi).x \notin \bigcap_{i \in I} A_i \iff \exists i \in I\,(x \notin A_i), \qquad x \notin \bigcup_{i \in I} A_i \iff \forall i \in I\,(x \notin A_i).

An xx is kept out of the intersection by a single refusing set, but kept out of the union only when every set refuses it.

Problem 4.4 (Informal).

Let I={1,2,3,4}I = \{1, 2, 3, 4\} and let AiA_i be the set of whole numbers mm with im2ii \leqslant m \leqslant 2i. Determine iIAi\bigcup_{i \in I} A_i and iIAi\bigcap_{i \in I} A_i.

Problem 4.5.

Let II be a non-empty set, let PP be a statement not involving ii, and let Q(i)Q(i) be a predicate on II. Prove the two exchange laws

PiIQ(i)iI(PQ(i)),PiIQ(i)iI(PQ(i)).P \land \exists i \in I\,Q(i) \equiv \exists i \in I\,\bigl(P \land Q(i)\bigr), \qquad P \land \forall i \in I\,Q(i) \equiv \forall i \in I\,\bigl(P \land Q(i)\bigr).

Where does the non-emptiness of II enter? Show that if I=I = \emptyset one of the two equivalences survives and the other fails.

Proposition 4.13 (Set difference over indexed families).

Let AA be a set and let {Bi}iI\{B_i\}_{i \in I} be an indexed family of sets with II non-empty. Then

  1. AiIBi=iI(ABi)A \setminus \bigcap_{i \in I} B_i = \bigcup_{i \in I} (A \setminus B_i);
  2. AiIBi=iI(ABi)A \setminus \bigcup_{i \in I} B_i = \bigcap_{i \in I} (A \setminus B_i).

Discussion.

Both are equalities of sets, so we compare membership on the two sides, and each comparison admits two readings. Elementwise, an element of AiIBiA \setminus \bigcap_{i \in I} B_i sits in AA and misses some BjB_j, so it sits in ABjA \setminus B_j and hence in the union of the differences; conversely, belonging to one difference ABjA \setminus B_j already keeps the element out of the intersection. The second identity is the same pair of thoughts with “some” replaced by “every”. The logical route says this through the dictionary: the definition turns membership in the intersection into a universal quantifier and membership in the union into an existential one, the negation rules swap \forall for \exists and back, and the exchange laws of the problem above push the fixed condition xAx \in A through the quantifier.

Proof (element style).

For the first, suppose xAiIBix \in A \setminus \bigcap_{i \in I} B_i. Then xAx \in A, but xx does not belong to every BiB_i, so xBjx \notin B_j for some jIj \in I. Hence xABjx \in A \setminus B_j, and therefore xiI(ABi)x \in \bigcup_{i \in I} (A \setminus B_i). Conversely, suppose xx belongs to that union. Then for some jIj \in I we have xABjx \in A \setminus B_j, so xAx \in A and xBjx \notin B_j. It follows that xiIBix \notin \bigcap_{i \in I} B_i, whence xAiIBix \in A \setminus \bigcap_{i \in I} B_i.

For the second, suppose xAiIBix \in A \setminus \bigcup_{i \in I} B_i. Then xAx \in A and xBix \notin B_i for every iIi \in I, so xABix \in A \setminus B_i for every iIi \in I, that is, xiI(ABi)x \in \bigcap_{i \in I} (A \setminus B_i). Conversely, membership in that intersection gives xABix \in A \setminus B_i for every iIi \in I, so xAx \in A and no BiB_i holds xx, which puts xx in AiIBiA \setminus \bigcup_{i \in I} B_i.

Proof (logical style).

For any xx,

xAiIBi(xA)¬iI(xBi)by the definitions(xA)iI(xBi)by quantifier negationiI((xA)(xBi))by the exchange lawxiI(ABi)by the definitions\begin{aligned} x \in A \setminus \bigcap_{i \in I} B_i &\equiv (x \in A) \land \neg\,\forall i \in I\,(x \in B_i) && \text{by the definitions} \\ &\equiv (x \in A) \land \exists i \in I\,(x \notin B_i) && \text{by quantifier negation} \\ &\equiv \exists i \in I\,\bigl((x \in A) \land (x \notin B_i)\bigr) && \text{by the exchange law} \\ &\equiv x \in \bigcup_{i \in I} (A \setminus B_i) && \text{by the definitions} \end{aligned}

and likewise

xAiIBi(xA)¬iI(xBi)by the definitions(xA)iI(xBi)by quantifier negationiI((xA)(xBi))by the exchange lawxiI(ABi)by the definitions.\begin{aligned} x \in A \setminus \bigcup_{i \in I} B_i &\equiv (x \in A) \land \neg\,\exists i \in I\,(x \in B_i) && \text{by the definitions} \\ &\equiv (x \in A) \land \forall i \in I\,(x \notin B_i) && \text{by quantifier negation} \\ &\equiv \forall i \in I\,\bigl((x \in A) \land (x \notin B_i)\bigr) && \text{by the exchange law} \\ &\equiv x \in \bigcap_{i \in I} (A \setminus B_i) && \text{by the definitions.} \end{aligned}

Corollary 4.14 (De Morgan's laws for indexed families).

Let {Bi}iI\{B_i\}_{i \in I} be an indexed family of subsets of an ambient set UU, with II non-empty. With every complement taken in UU,

iIBi=iIBi,iIBi=iIBi.\overline{\bigcap_{i \in I} B_i} = \bigcup_{i \in I} \overline{B_i}, \qquad \overline{\bigcup_{i \in I} B_i} = \bigcap_{i \in I} \overline{B_i}.

Proof.

Take A=UA = U in the two parts of the proposition. Each difference UBiU \setminus B_i is the complement Bi\overline{B_i}, and the identities follow.

Problem 4.6.

Let AA be a set and {Bi}iI\{B_i\}_{i \in I} an indexed family of sets with II non-empty. Prove that AiIBiA \subset \bigcap_{i \in I} B_i if and only if ABiA \subset B_i for every iIi \in I, and that iIBiA\bigcup_{i \in I} B_i \subset A if and only if BiAB_i \subset A for every iIi \in I.

Problem 4.7.

Let {Ai,j}(i,j)I×J\{A_{i,j}\}_{(i,j) \in I \times J} be an indexed family of sets with II and JJ non-empty. Decide which inclusion between

iIjJAi,jandjJiIAi,j\bigcup_{i \in I} \bigcap_{j \in J} A_{i,j} \qquad\text{and}\qquad \bigcap_{j \in J} \bigcup_{i \in I} A_{i,j}

holds for every such family, and whether equality is forced. (Harder.)

Functions

In order to do analysis it is not particularly useful to have only the notion of a set; we also need the notion of a function from one set to another. Informally, a function f:XYf : X \to Y is an operation which assigns to each element, or input, xx in XX a single element, or output, f(x)f(x) in YY. Formulas, rules and graphs are convenient ways to describe the pairing of inputs with outputs, but the set of pairs itself is the function.

Definition 4.15 (Function).

Let XX and YY be sets. A function from XX to YY is a subset fX×Yf \subset X \times Y such that for every xXx \in X there is exactly one yYy \in Y with (x,y)f(x, y) \in f. We write f:XYf : X \to Y, call XX the domain of ff, written domf\operatorname{dom} f, and YY the codomain, and write f(x)f(x) for the unique yy paired with xx, so that for any xXx \in X and yYy \in Y,

y=f(x)    (x,y)f.y = f(x) \iff (x, y) \in f.

The condition on ff is sometimes called the vertical line test: exactly one pair of ff stands above each point of the domain. It is two demands at once, existence and uniqueness, and either can fail on its own.

We also write xf(x)x \mapsto f(x) for the pairing. The object f(x)f(x) is the image of xx, and xx is a preimage of f(x)f(x), one of possibly several. Functions are also called maps, mappings or transformations, depending on the context.

Remark.

A function is often handed to us as a property rather than a set of pairs. Let P(x,y)P(x, y) pertain to xXx \in X and yYy \in Y, and suppose that for every xXx \in X there is exactly one yYy \in Y making P(x,y)P(x, y) true. Then

f  =def  {pX×Y    xX yY(p=(x,y)P(x,y))}f \;\defeq\; \bigl\{p \in X \times Y \;\big|\; \exists x \in X\ \exists y \in Y\,\bigl(p = (x, y) \land P(x, y)\bigr)\bigr\}

is a set by comprehension, and the hypothesis on PP is exactly the vertical line test, so ff is a function from XX to YY with y=f(x)y = f(x) precisely when P(x,y)P(x, y) holds. No further axiom is needed to turn a property into a function; the ones we already have build the set of pairs for us.

Example 4.16 (Informal).

Assuming you know what the real numbers are, take both domain and codomain to be them. The declaration g(x)=1/xg(x) = 1/x assigns nothing at x=0x = 0, so existence fails there and gg is not a function on that domain. The condition h(x)2=x2h(x)^2 = x^2 offers two candidates whenever x0x \neq 0, namely xx and x-x, so uniqueness fails and hh is not a function either.

Remark (Informal examples).

Several examples below assume you know the real numbers and the whole numbers, which we have not built yet. In those we write RR for the real numbers and WW for the whole numbers, and we borrow the rules of school algebra openly. Nothing in the theory rests on them; they are there because familiar objects make the definitions easier to read.

A rule that meets both requirements, assigning a unique value in the codomain to every element of the domain, is said to be well defined. One common way to present a function is to specify its domain, its codomain, and how the output f(x)f(x) is generated from each input; this is an explicit definition.

Remark.

Functions obey substitution: if x=xx = x' then f(x)=f(x)f(x) = f(x'), since f(x)f(x) was defined as the unique yy paired with xx, and xx and xx' name the same object. Equal inputs give equal outputs. Unequal inputs need not give unequal outputs, as a constant map shows.

Three functions occur often enough to deserve names.

Definition 4.17 (Inclusion, identity and constant maps).

Let STS \subset T. The inclusion map ι:ST\iota : S \to T is defined by ι(x)=defx\iota(x) \defeq x. When S=TS = T this is the identity map on SS, written idS\mathrm{id}_S. For sets AA and BB and a fixed b0Bb_0 \in B, the constant map with value b0b_0 is c:ABc : A \to B given by c(a)=defb0c(a) \defeq b_0 for every aAa \in A.

Example 4.18.

There is a function from \emptyset to any set BB, namely the empty set of pairs. Neither requirement can find an element of \emptyset on which to fail, so both hold vacuously. It is a dull function, but a function all the same, and we shall see below that it is the only one from \emptyset to BB.

When the domain and codomain are sets of real numbers we can plot the pairs of fA×Bf \subset A \times B in the Cartesian plane to draw its graph; for q(x)=x2q(x) = x^2 this yields the familiar parabola. An arbitrary domain might admit no geometric picture, but the underlying set of pairs remains. Read this way the three named maps become shapes: the identity on SS is the diagonal, since it pairs each xx with itself, and a constant map is a horizontal line.

Proposition 4.19 (Equality of functions).

Functions ff and gg are equal if and only if they have the same domain and f(x)=g(x)f(x) = g(x) for every xx in it.

Discussion.

We prove the two implications of the biconditional. Suppose first that f=gf = g. Equality of the sets of ordered pairs gives equality of their first coordinates, hence equality of the domains; for an arbitrary element of the common domain the pair (x,f(x))(x, f(x)) belongs to gg, and the uniqueness clause of Definition 4.15 gives f(x)=g(x)f(x) = g(x). Conversely, assume the domains agree and the two functions have the same value at every point of the common domain. By mutual inclusion it is enough to prove the two inclusions. An arbitrary (x,y)f(x, y) \in f has xx in the domain and y=f(x)y = f(x), so the hypotheses put (x,y)(x, y) in gg; the reverse inclusion follows symmetrically.

Proof (element style).

Suppose first that f=gf = g. The domain of a function consists of the first coordinates of its elements, so ff and gg have the same domain. For any xx in it the pair (x,f(x))(x, f(x)) belongs to ff, and since f=gf = g we have (x,f(x))g(x, f(x)) \in g, which gives f(x)=g(x)f(x) = g(x) by the uniqueness of images in gg.

Conversely, assume the domains agree and f(x)=g(x)f(x) = g(x) for every xx in the common domain. If (x,y)f(x, y) \in f, then xx lies in that domain and y=f(x)y = f(x); since f(x)=g(x)f(x) = g(x) we have y=g(x)y = g(x), so (x,y)g(x, y) \in g. Hence fgf \subset g. A symmetric argument gives gfg \subset f, so f=gf = g.

Proof (logical style).

If f=gf = g, then for every xx,

xdomfy((x,y)f)y((x,y)g)xdomg,\begin{aligned} x \in \operatorname{dom} f &\equiv \exists y\,\bigl((x, y) \in f\bigr) \\ &\equiv \exists y\,\bigl((x, y) \in g\bigr) \equiv x \in \operatorname{dom} g, \end{aligned}

and for xx in this common domain (x,f(x))f=g(x, f(x)) \in f = g, so uniqueness gives f(x)=g(x)f(x) = g(x). Conversely, for every ordered pair (x,y)(x, y),

(x,y)f(xdomf)(y=f(x))(xdomg)(y=g(x))(x,y)g.\begin{aligned} (x, y) \in f &\equiv (x \in \operatorname{dom} f) \land \bigl(y = f(x)\bigr) \\ &\equiv (x \in \operatorname{dom} g) \land \bigl(y = g(x)\bigr) \equiv (x, y) \in g. \end{aligned}

Remark.

The codomain does not enter the criterion, because under Definition 4.15 a function is simply its set of ordered pairs. Consequently the set {(x,x)xS}\{(x, x) \mid x \in S\} defines the identity map idS:SS\mathrm{id}_S : S \to S, but for any TT with STS \subset T it equally defines the inclusion map ι:ST\iota : S \to T. The set of pairs is identical; the declared codomain matters when we ask whether every element of the target is reached.

Example 4.20.

There is only one function from \emptyset to a given set XX. Any two have the same domain, namely \emptyset, and agree at every point of it, since there are none, so the proposition makes them equal.

Definition 4.21 (Restriction and extension).

Let g:BCg : B \to C be a function and let ABA \subset B. The restriction of gg to AA is the function gA:ACg|_A : A \to C given by gA(x)=defg(x)g|_A(x) \defeq g(x). The function gg is called an extension of gAg|_A to BB.

Example 4.22 (Informal).

Consider

f:WR,f(x)=defx21,g:RR,g(x)=defx21,h:RR,h(x)=def(x1)(x+1).\begin{aligned} f &: W \to R, & f(x) &\defeq x^2 - 1, \\ g &: R \to R, & g(x) &\defeq x^2 - 1, \\ h &: R \to R, & h(x) &\defeq (x - 1)(x + 1). \end{aligned}

By the proposition, g=hg = h: the domains agree, and the rules of school algebra give (x1)(x+1)=x21(x-1)(x+1) = x^2 - 1 for every real number. The function ff is a different object entirely. Its domain is WW, so it cannot equal gg or hh, even though its values agree with theirs at every whole number. It is their common restriction, f=gW=hWf = g|_W = h|_W. Equality of functions depends on domains, not on formulas.

Remark.

Definition 4.15 builds a function as a set of pairs, and the domain and codomain are read off the notation f:XYf : X \to Y rather than carried by the set. A tidier alternative is to package all three, taking a function to be the ordered triple (X,Y,G)(X, Y, G) of a domain, a codomain and a set GX×YG \subset X \times Y obeying the vertical line test. Nothing in what follows depends on the choice, and the problems below ask you to check that the two accounts agree.

Problem 4.8.

Let A={1,2,3}A = \{1, 2, 3\} and B={r,s}B = \{r, s\}. Which of the following are functions from AA to BB? Justify each answer.

  1. {(1,r),(2,s),(3,r)}\{(1, r), (2, s), (3, r)\};
  2. {(1,r),(2,s)}\{(1, r), (2, s)\};
  3. {(1,r),(1,s),(2,r),(3,s)}\{(1, r), (1, s), (2, r), (3, s)\}.

Problem 4.9.

Give sets AA and BB for which f={(3,2),(1,1),(8,5),(9,4),(π,1)}f = \{(3, 2), (1, 1), (8, 5), (9, -4), (\pi, 1)\} is a function from AA to BB. What is f(8)f(8), and what are the preimages of 11? Is your choice of AA and BB the only one?

Problem 4.10.

Let XX and YY be non-empty sets. Prove that X×YX \times Y is a function from XX to YY if and only if YY has exactly one element.

Problem 4.11.

Let f:XYf : X \to Y be a function and define its graph to be the subset {(x,f(x))xX}\{(x, f(x)) \mid x \in X\} of X×YX \times Y.

  1. Show that two functions f,f~:XYf, \tilde{f} : X \to Y are equal if and only if they have the same graph.
  2. Conversely, let GX×YG \subset X \times Y be such that for each xXx \in X the set {yY(x,y)G}\{y \in Y \mid (x, y) \in G\} has exactly one element. Show that there is exactly one function f:XYf : X \to Y whose graph is GG.
  3. Suppose we define a function instead to be an ordered triple (X,Y,G)(X, Y, G) with GX×YG \subset X \times Y obeying the vertical line test, taking the domain to be XX, the codomain YY, and f(x)f(x) the unique yy with (x,y)G(x, y) \in G. Show that this definition agrees with Definition 4.15 , in the sense that every choice of domain, codomain and property obeying the vertical line test produces a function in this sense with all the properties the earlier definition requires.

Images and Preimages

Definition 4.23 (Image of a set).

Let f:ABf : A \to B be a function and let SAS \subset A. The image of SS under ff is f(S)=def{f(x)xS}f(S) \defeq \{f(x) \mid x \in S\}. The image of the whole domain is the range of ff, written imf=deff(A)\operatorname{im} f \defeq f(A).

The range is a subset of the codomain, and it may be a proper one. In terms of the ordered pairs of Definition 4.15 ,

imf={yB    xA((x,y)f)}={yB    xA(f(x)=y)}.\begin{aligned} \operatorname{im} f &= \bigl\{y \in B \;\big|\; \exists x \in A\,\bigl((x, y) \in f\bigr)\bigr\} \\ &= \bigl\{y \in B \;\big|\; \exists x \in A\,\bigl(f(x) = y\bigr)\bigr\}. \end{aligned}

Definition 4.24 (Preimage of a set).

Let f:ABf : A \to B be a function and let UBU \subset B. The preimage of UU under ff is f1(U)=def{xAf(x)U}f^{-1}(U) \defeq \{x \in A \mid f(x) \in U\}. In particular f1({y})={xAf(x)=y}f^{-1}(\{y\}) = \{x \in A \mid f(x) = y\} is the set of all preimages of yBy \in B.

The notation f1(U)f^{-1}(U) does not assume that ff has an inverse function; the definition applies to every function. The set f1({y})f^{-1}(\{y\}) may be empty, may hold one element, or may hold several.

Example 4.25.

Let A={1,2,3,4}A = \{1, 2, 3, 4\} and B={r,s,t,u}B = \{r, s, t, u\}, and define f:ABf : A \to B by f(1)=defrf(1) \defeq r, f(2)=defsf(2) \defeq s, f(3)=defsf(3) \defeq s, f(4)=deftf(4) \defeq t. Then f({1,3})={r,s}f(\{1, 3\}) = \{r, s\}, f({2,3,4})={s,t}f(\{2, 3, 4\}) = \{s, t\} and imf={r,s,t}\operatorname{im} f = \{r, s, t\}. The element uu belongs to the codomain but not to the range, and its point preimage is empty. In general f1({y})f^{-1}(\{y\}) is non-empty exactly when yimfy \in \operatorname{im} f, and how many elements it holds records how many inputs are sent to yy. Here f1({s})={2,3}f^{-1}(\{s\}) = \{2, 3\}, f1({r,t})={1,4}f^{-1}(\{r, t\}) = \{1, 4\} and f1({u})=f^{-1}(\{u\}) = \emptyset.

Example 4.26 (Informal).

Take g:RRg : R \to R with g(x)=defx+1g(x) \defeq x + 1, and let SS be the set of real numbers xx with 0x20 \leqslant x \leqslant 2. Then g(S)g(S) is the set of real numbers yy with 1y31 \leqslant y \leqslant 3: on the one hand 0x20 \leqslant x \leqslant 2 gives 1x+131 \leqslant x + 1 \leqslant 3, which proves one inclusion, and on the other, any such yy has y1y - 1 in SS with g(y1)=yg(y - 1) = y, which proves the reverse. The same calculation read backwards gives g1(g(S))=Sg^{-1}\bigl(g(S)\bigr) = S.

Proposition 4.27 (Set laws for preimages).

Let f:ABf : A \to B be a function and let U,VBU, V \subset B. Then

  1. f1(BU)=Af1(U)f^{-1}(B \setminus U) = A \setminus f^{-1}(U);
  2. f1(UV)=f1(U)f1(V)f^{-1}(U \cup V) = f^{-1}(U) \cup f^{-1}(V);
  3. f1(UV)=f1(U)f1(V)f^{-1}(U \cap V) = f^{-1}(U) \cap f^{-1}(V).

Discussion.

We prove each equality by comparing membership at an arbitrary xx. By the definition of the preimage, membership says that xAx \in A and that its image has the required property. So f(x)BUf(x) \in B \setminus U says precisely that f(x)Uf(x) \notin U; membership in UVU \cup V means membership in at least one of UU and VV; and membership in UVU \cap V means membership in both. Translating those three conditions back through the same definition yields the complement, the union and the intersection we want.

Proof (element style).

If xf1(BU)x \in f^{-1}(B \setminus U), then xAx \in A and f(x)Uf(x) \notin U, so xAf1(U)x \in A \setminus f^{-1}(U). Conversely, if xAf1(U)x \in A \setminus f^{-1}(U), then f(x)Uf(x) \notin U; since f(x)Bf(x) \in B this puts f(x)BUf(x) \in B \setminus U, whence xf1(BU)x \in f^{-1}(B \setminus U).

If xf1(UV)x \in f^{-1}(U \cup V), then f(x)f(x) belongs to UU or to VV, so xx belongs to f1(U)f1(V)f^{-1}(U) \cup f^{-1}(V). Conversely, membership in that union puts xx in one of the two preimages, so f(x)UVf(x) \in U \cup V and xf1(UV)x \in f^{-1}(U \cup V).

Finally xf1(UV)x \in f^{-1}(U \cap V) gives both f(x)Uf(x) \in U and f(x)Vf(x) \in V, so xf1(U)f1(V)x \in f^{-1}(U) \cap f^{-1}(V); and membership in both preimages gives f(x)UVf(x) \in U \cap V, which is the reverse inclusion.

Proof (logical style).

For every xx,

xf1(BU)(xA)(f(x)U)xAf1(U),xf1(UV)(xA)((f(x)U)(f(x)V))(xf1(U))(xf1(V))xf1(U)f1(V),xf1(UV)(xA)((f(x)U)(f(x)V))(xf1(U))(xf1(V))xf1(U)f1(V).\begin{aligned} x \in f^{-1}(B \setminus U) &\equiv (x \in A) \land \bigl(f(x) \notin U\bigr) \equiv x \in A \setminus f^{-1}(U), \\[2pt] x \in f^{-1}(U \cup V) &\equiv (x \in A) \land \bigl((f(x) \in U) \lor (f(x) \in V)\bigr) \\ &\equiv \bigl(x \in f^{-1}(U)\bigr) \lor \bigl(x \in f^{-1}(V)\bigr) \equiv x \in f^{-1}(U) \cup f^{-1}(V), \\[2pt] x \in f^{-1}(U \cap V) &\equiv (x \in A) \land \bigl((f(x) \in U) \land (f(x) \in V)\bigr) \\ &\equiv \bigl(x \in f^{-1}(U)\bigr) \land \bigl(x \in f^{-1}(V)\bigr) \equiv x \in f^{-1}(U) \cap f^{-1}(V). \end{aligned}

The middle steps distribute the conjunct xAx \in A across the disjunction and the conjunction, which is Distributivity and, for the third line, Idempotence. The membership conditions agree in each pair, so the corresponding sets are equal.

Preimages preserve complements, unions and intersections. Images preserve unions, but need not preserve intersections, as the problems below ask you to show.

Read as the assignments Sf(S)S \mapsto f(S) and Uf1(U)U \mapsto f^{-1}(U), a function f:ABf : A \to B induces two maps between power sets, one from P(A)\mathcal{P}(A) to P(B)\mathcal{P}(B) and one from P(B)\mathcal{P}(B) to P(A)\mathcal{P}(A), written ff and f1f^{-1} again. The two behave differently, and the proposition is the reason: the preimage map preserves all three operations, while the image map preserves only unions.

Remark.

This asymmetry is why continuity is later stated in terms of preimages rather than images: a function is continuous exactly when the preimage of every open set is open.

Problem 4.12.

For the finite function above, determine f()f(\emptyset), f({1,4})f(\{1, 4\}), f1({r,s})f^{-1}(\{r, s\}) and f1({s,u})f^{-1}(\{s, u\}).

Problem 4.13.

Let f:ABf : A \to B be a function and let S,TAS, T \subset A. Prove that f(ST)=f(S)f(T)f(S \cup T) = f(S) \cup f(T). Must f(ST)=f(S)f(T)f(S \cap T) = f(S) \cap f(T) always hold?

Surjections, Injections, Bijections

Definition 4.28 (Surjection).

A function f:ABf : A \to B is surjective, or onto BB, if f(A)=Bf(A) = B; equivalently, if for every yBy \in B there is some xAx \in A with f(x)=yf(x) = y.

Every function is surjective onto its range.

Example 4.29 (Informal).

The successor map s:WWs : W \to W given by s(n)=defn+1s(n) \defeq n + 1 is not surjective, since 00 has no preimage among the whole numbers. The same ordered pairs define a surjection onto W{0}W \setminus \{0\}. So surjectivity depends on the declared codomain, not on the pairs alone.

Definition 4.30 (Injection).

A function f:ABf : A \to B is injective, or one-to-one, if for all x1,x2Ax_1, x_2 \in A, f(x1)=f(x2)    x1=x2f(x_1) = f(x_2) \implies x_1 = x_2.

The contrapositive of that implication says distinct inputs have distinct images. To show a function is not injective it is enough to give two distinct inputs with the same image; to show it is not surjective it is enough to give an element of the codomain with no preimage.

Proposition 4.31 (Point preimages).

Let f:ABf : A \to B be a function.

  1. ff is injective if and only if f1({y})f^{-1}(\{y\}) holds at most one element for every yBy \in B;
  2. ff is surjective if and only if f1({y})f^{-1}(\{y\}) is non-empty for every yBy \in B.

Discussion.

For the first part we compare the definition of injectivity with the assertion that two members of f1({y})f^{-1}(\{y\}) coincide. In one direction two such members have equal images; in the other, equal images make the two inputs members of one point preimage. For the second part, the definition of the preimage says f1({y})f^{-1}(\{y\}) is non-empty exactly when some xAx \in A satisfies f(x)=yf(x) = y, which is what surjectivity asks.

Proof.

Suppose ff is injective. If x1,x2f1({y})x_1, x_2 \in f^{-1}(\{y\}), then f(x1)=y=f(x2)f(x_1) = y = f(x_2), so x1=x2x_1 = x_2. Conversely, suppose every point preimage holds at most one element. Whenever f(x1)=f(x2)=yf(x_1) = f(x_2) = y, both x1x_1 and x2x_2 belong to f1({y})f^{-1}(\{y\}), and hence they are equal. This proves the first part.

The second is the surjectivity condition rewritten: f1({y})f^{-1}(\{y\}) is non-empty exactly when some xAx \in A satisfies f(x)=yf(x) = y.

Example 4.32 (Informal).

For a real number cc, the translation τc:RR\tau_c : R \to R given by τc(x)=defx+c\tau_c(x) \defeq x + c is injective and surjective. If τc(x1)=τc(x2)\tau_c(x_1) = \tau_c(x_2), then x1+c=x2+cx_1 + c = x_2 + c, and adding c-c to both sides gives x1=x2x_1 = x_2. For surjectivity, take any yy and put x=ycx = y - c; then τc(x)=(yc)+c=y\tau_c(x) = (y - c) + c = y, so every element of the codomain has a preimage.

Example 4.33 (Informal).

The squaring map q:RRq : R \to R with q(x)=defx2q(x) \defeq x^2 is neither injective nor surjective: q(1)=q(1)q(-1) = q(1), and 1-1 lies outside its range because every square is non-negative.

Example 4.34 (Informal).

The product map m:W×WWm : W \times W \to W with m(a,b)=defabm(a, b) \defeq ab is surjective, since m(n,1)=nm(n, 1) = n for every whole number nn. It is not injective, since m(1,6)=m(2,3)m(1, 6) = m(2, 3) while (1,6)(2,3)(1, 6) \neq (2, 3) by Proposition 4.2 .

Problem 4.14.

For the finite function of the previous section, decide whether it is injective and whether it is surjective, justifying each answer from the definitions.

Problem 4.15.

Let AA be non-empty and let BB have exactly two elements. How many functions from AA to BB are not surjective?

Bijections

Definition 4.35 (Bijection).

A function f:ABf : A \to B is bijective, or a bijection, if it is both injective and surjective. A bijection from AA to BB is also called a one-to-one correspondence between them.

Surjectivity asks for at least one preimage of each point of the codomain and injectivity permits at most one, so a bijection has exactly one.

Proposition 4.36 (Unique preimages).

A function f:ABf : A \to B is bijective if and only if for every yBy \in B there is a unique xAx \in A with f(x)=yf(x) = y.

Discussion.

We use the two parts of Proposition 4.31 . If ff is bijective, surjectivity gives a preimage of each yBy \in B and injectivity shows no second preimage is possible. Conversely, existence of a preimage for every yy gives surjectivity, and its uniqueness gives injectivity. The same criterion is what will let us reverse the ordered pairs of a bijection later.

Proof.

Suppose first that ff is bijective. Surjectivity supplies, for each yBy \in B, an xAx \in A with f(x)=yf(x) = y. If x1x_1 and x2x_2 both have this property, then f(x1)=f(x2)f(x_1) = f(x_2), so injectivity gives x1=x2x_1 = x_2.

Conversely, suppose every yBy \in B has exactly one preimage. Existence makes ff surjective. If f(x1)=f(x2)f(x_1) = f(x_2), both x1x_1 and x2x_2 are preimages of the same element of BB, so uniqueness gives x1=x2x_1 = x_2 and ff is injective as well.

For finite sets, an injection from AA to BB needs at least as many elements in BB as in AA, and a surjection needs at least as many in AA as in BB; a bijection therefore forces the two to have the same number of elements. Comparing sets by functions rather than by counting is what will extend this to infinite sets, where counting is no longer available.

Example 4.37.

With A={1,2,3,4}A = \{1, 2, 3, 4\} and B={r,s,t,u}B = \{r, s, t, u\} as above, take β=def{(1,s),(2,u),(3,r),(4,t)}\beta \defeq \{(1, s), (2, u), (3, r), (4, t)\}. Each member of AA appears once as a first coordinate and each member of BB once as a second, so β:AB\beta : A \to B is a bijection. The function ff of the previous section is neither injective nor surjective: ss is hit twice and uu is not hit at all.

Proposition 4.38 (An injection onto its range).

If f:ABf : A \to B is injective, then the function from AA to f(A)f(A) with the same ordered pairs is bijective.

Discussion.

The new function has the same ordered pairs as ff, so injectivity carries over unchanged, the definition mentioning only inputs and their images. For surjectivity, take yy in the new codomain f(A)f(A); the definition of the image provides an xAx \in A with f(x)=yf(x) = y, which is the preimage required.

Proof.

Changing the codomain from BB to f(A)f(A) does not alter the ordered pairs, and injectivity is a condition on those alone, so the new function is injective. Every yf(A)y \in f(A) is f(x)f(x) for some xAx \in A by the definition of the image, so it is also surjective.

Every translation is a bijection, by the example above, and so is the identity map idA\mathrm{id}_A, since each yAy \in A is its own unique preimage. The squaring map and the product map are not, each having already failed one of the two conditions.

Problem 4.16.

Let f:ABf : A \to B be bijective and let SAS \subset A. Prove that the restriction fS:Sf(S)f|_S : S \to f(S) is bijective.

Problem 4.17.

Let f:ABf : A \to B be injective and let S,TAS, T \subset A. Prove that f(ST)=f(S)f(T)f(S \cap T) = f(S) \cap f(T).

Problem 4.18.

Let AA, BB and CC be sets. Prove that

(x,(y,z))((x,y),z)\bigl(x, (y, z)\bigr) \longmapsto \bigl((x, y), z\bigr)

is a bijection from A×(B×C)A \times (B \times C) onto (A×B)×C(A \times B) \times C, so that the two readings of a triple product agree up to that correspondence. Show also that the two sets are not in general equal, by exhibiting an element of one which is not an element of the other.

Composition

Definition 4.39 (Composition).

Let f:ABf : A \to B and g:BCg : B \to C be functions. Their composition is the function gf:ACg \circ f : A \to C given by (gf)(x)=defg(f(x))(g \circ f)(x) \defeq g(f(x)).

The notation is read from right to left: ff acts first and gg second. The codomain of ff must be the domain of gg, so that every value of ff can serve as an input of gg.

Example 4.40 (Informal).

For the squaring map qq and the translation τ1\tau_1 above, (qτ1)(x)=(x+1)2(q \circ \tau_1)(x) = (x + 1)^2 while (τ1q)(x)=x2+1(\tau_1 \circ q)(x) = x^2 + 1. At x=1x = 1 these take the values 44 and 22, so qτ1τ1qq \circ \tau_1 \neq \tau_1 \circ q by Proposition 4.19 . Composition is not commutative.

Theorem 4.41 (Associativity of composition).

Let f:ABf : A \to B, g:BCg : B \to C and h:CDh : C \to D be functions. Then h(gf)=(hg)fh \circ (g \circ f) = (h \circ g) \circ f.

Discussion.

By Proposition 4.19 we must check that the two functions have the same domain and agree at every input. Both are functions from AA to DD, so only the values are in question, and at an arbitrary xAx \in A the definition of composition evaluates either side by applying ff, then gg, then hh.

Proof.

Both sides have domain AA. For every xAx \in A, (h(gf))(x)=h(g(f(x)))=((hg)f)(x),\bigl(h \circ (g \circ f)\bigr)(x) = h\bigl(g(f(x))\bigr) = \bigl((h \circ g) \circ f\bigr)(x), so Proposition 4.19 gives the equality.

Associativity lets us write hgfh \circ g \circ f without brackets. The identity maps satisfy the identity laws one expects.

Proposition 4.42 (Identity laws).

If f:ABf : A \to B, then idBf=f\mathrm{id}_B \circ f = f and fidA=ff \circ \mathrm{id}_A = f.

Discussion.

Again Proposition 4.19 reduces each identity to a comparison of domains and values. Both sides of each have domain AA, and at an arbitrary xAx \in A the definitions of composition and of the identity map reduce both composites to f(x)f(x).

Proof.

For every xAx \in A we have (idBf)(x)=idB(f(x))=f(x)(\mathrm{id}_B \circ f)(x) = \mathrm{id}_B(f(x)) = f(x) and (fidA)(x)=f(idA(x))=f(x)(f \circ \mathrm{id}_A)(x) = f(\mathrm{id}_A(x)) = f(x). Each pair of functions has the same domain, so Proposition 4.19 applies.

Theorem 4.43 (Composition and bijections).

Let f:ABf : A \to B and g:BCg : B \to C be functions.

  1. If ff and gg are injective, then gfg \circ f is injective;
  2. If ff and gg are surjective, then gfg \circ f is surjective;
  3. If ff and gg are bijective, then gfg \circ f is bijective.

Discussion.

For the first part the definition of injectivity asks us to start from an equality of composite values; expanding the composition, injectivity of gg gives equality of the ff-values, and injectivity of ff then gives equality of the inputs. For the second, take an arbitrary zCz \in C, choose yBy \in B with g(y)=zg(y) = z, then choose xAx \in A with f(x)=yf(x) = y, and evaluate the composite at xx. The third is the first two together with the definition of a bijection.

Proof.

Suppose (gf)(x1)=(gf)(x2)(g \circ f)(x_1) = (g \circ f)(x_2), that is, g(f(x1))=g(f(x2))g(f(x_1)) = g(f(x_2)). Injectivity of gg gives f(x1)=f(x2)f(x_1) = f(x_2), and injectivity of ff then gives x1=x2x_1 = x_2, which is the first part.

For the second, take zCz \in C. Since gg is surjective, some yBy \in B has g(y)=zg(y) = z; since ff is surjective, some xAx \in A has f(x)=yf(x) = y. Then (gf)(x)=g(f(x))=g(y)=z(g \circ f)(x) = g(f(x)) = g(y) = z. The third part follows from the other two.

Problem 4.19.

Let f:ABf : A \to B and g:BCg : B \to C. Prove that if gfg \circ f is injective then ff is injective, and that if gfg \circ f is surjective then gg is surjective.

Problem 4.20.

Construct finite sets AA, BB, CC and functions f:ABf : A \to B, g:BCg : B \to C for which gfg \circ f is bijective although ff is not surjective and gg is not injective.

Inverse Functions

Definition 4.44 (Inverse function).

Let f:ABf : A \to B and g:BAg : B \to A be functions. The function gg is an inverse of ff if gf=idAg \circ f = \mathrm{id}_A and fg=idBf \circ g = \mathrm{id}_B. A function which has an inverse is called invertible.

The first equation returns each element of AA after applying ff and then gg; the second does the same for BB. The problems below examine what each equation achieves on its own.

Theorem 4.45 (Invertibility and bijections).

A function is invertible if and only if it is bijective, and when an inverse exists it is unique.

Discussion.

Suppose first that gg is an inverse of ff. To get injectivity, apply gg to an equality f(x1)=f(x2)f(x_1) = f(x_2) and use gf=idAg \circ f = \mathrm{id}_A; to get surjectivity, use g(y)g(y) as a preimage of an arbitrary yBy \in B and use fg=idBf \circ g = \mathrm{id}_B. Conversely, Proposition 4.36 gives exactly one reversed pair (y,x)(y, x) for each yBy \in B, so the set of reversed pairs passes the vertical line test and is a function from BB to AA; the two inverse identities are then those pairs read in the two directions. For uniqueness, two inverses are compared by sandwiching ff between them, where associativity and the identity laws collapse the composite in two ways.

Proof.

Let f:ABf : A \to B have an inverse g:BAg : B \to A. If f(x1)=f(x2)f(x_1) = f(x_2), then x1=g(f(x1))=g(f(x2))=x2x_1 = g(f(x_1)) = g(f(x_2)) = x_2, so ff is injective. Given yBy \in B, put x=g(y)x = g(y); the second identity gives f(x)=f(g(y))=yf(x) = f(g(y)) = y, so ff is surjective.

Conversely, suppose ff is bijective and set g=def{(y,x)B×A(x,y)f}g \defeq \{(y, x) \in B \times A \mid (x, y) \in f\}. For each yBy \in B, Proposition 4.36 gives a unique xAx \in A with f(x)=yf(x) = y, so gg is a function from BB to AA. Reading the pairs in each direction gives g(f(x))=xg(f(x)) = x for xAx \in A and f(g(y))=yf(g(y)) = y for yBy \in B, that is, gf=idAg \circ f = \mathrm{id}_A and fg=idBf \circ g = \mathrm{id}_B.

For uniqueness, let gg and hh both be inverses of ff. Associativity and the identity laws give

g=idAg=(hf)g=h(fg)=hidB=h.g = \mathrm{id}_A \circ g = (h \circ f) \circ g = h \circ (f \circ g) = h \circ \mathrm{id}_B = h.

The unique inverse of a bijection ff is written f1f^{-1}. The construction in the proof gives

f1={(y,x)B×A(x,y)f},sof1(y)=x    f(x)=y.f^{-1} = \{(y, x) \in B \times A \mid (x, y) \in f\}, \qquad\text{so}\qquad f^{-1}(y) = x \iff f(x) = y.

Remark.

The symbol f1f^{-1} also denotes the preimage of a set. The two uses are distinct: f1(y)f^{-1}(y) is an element of AA produced by the inverse function, and exists only for a bijection, while f1(U)f^{-1}(U) is a subset of AA and is defined for every function. For a bijection they are related by f1({y})={f1(y)}f^{-1}(\{y\}) = \{f^{-1}(y)\}, the preimage of a point being the singleton of its inverse image.

Example 4.46.

Reversing the pairs of the bijection β={(1,s),(2,u),(3,r),(4,t)}\beta = \{(1, s), (2, u), (3, r), (4, t)\} gives β1={(s,1),(u,2),(r,3),(t,4)}\beta^{-1} = \{(s, 1), (u, 2), (r, 3), (t, 4)\}. Also idA1=idA\mathrm{id}_A^{-1} = \mathrm{id}_A for any set AA.

Example 4.47 (Informal).

The translations invert one another: τc1=τc\tau_c^{-1} = \tau_{-c}, since τc(τc(x))=x=τc(τc(x))\tau_{-c}(\tau_c(x)) = x = \tau_c(\tau_{-c}(x)) for every real number xx.

Proposition 4.48 (The inverse is a bijection).

If f:ABf : A \to B is bijective, then f1:BAf^{-1} : B \to A is bijective and (f1)1=f(f^{-1})^{-1} = f.

Discussion.

The two equations defining an inverse are symmetric in ff and f1f^{-1}, so they say equally that ff is an inverse of f1f^{-1}. That makes f1f^{-1} invertible, and the theorem above turns invertibility into bijectivity; its uniqueness clause then names ff as the inverse of f1f^{-1}.

Proof.

The identities f1f=idAf^{-1} \circ f = \mathrm{id}_A and ff1=idBf \circ f^{-1} = \mathrm{id}_B also say that ff is an inverse of f1f^{-1}. So f1f^{-1} is invertible and hence bijective by Theorem 4.45 , and uniqueness of its inverse gives (f1)1=f(f^{-1})^{-1} = f.

Theorem 4.49 (Inverse of a composition).

If f:ABf : A \to B and g:BCg : B \to C are bijections, then (gf)1=f1g1(g \circ f)^{-1} = f^{-1} \circ g^{-1}.

Discussion.

Put k=deff1g1k \defeq f^{-1} \circ g^{-1}. Rather than compute (gf)1(g \circ f)^{-1} we show directly that kk meets the definition of an inverse of gfg \circ f: evaluate k(gf)k \circ (g \circ f) at an arbitrary xAx \in A and (gf)k(g \circ f) \circ k at an arbitrary zCz \in C, where associativity and the inverse identities cancel the adjacent pairs. Since gfg \circ f is bijective, uniqueness of inverses then identifies kk as the one.

Proof.

Put k=deff1g1:CAk \defeq f^{-1} \circ g^{-1} : C \to A. For xAx \in A and zCz \in C,

(k(gf))(x)=f1(g1(g(f(x))))=x,((gf)k)(z)=g(f(f1(g1(z))))=z.\bigl(k \circ (g \circ f)\bigr)(x) = f^{-1}\bigl(g^{-1}(g(f(x)))\bigr) = x, \qquad \bigl((g \circ f) \circ k\bigr)(z) = g\bigl(f(f^{-1}(g^{-1}(z)))\bigr) = z.

So kk is an inverse of gfg \circ f, which is bijective by Theorem 4.43 , and uniqueness in Theorem 4.45 gives the formula.

Corollary 4.50 (Cancellation by a bijection).

Let f:BCf : B \to C be bijective and let g,h:ABg, h : A \to B. Then fg=fhf \circ g = f \circ h implies g=hg = h. Likewise, if f:ABf : A \to B is bijective and r,s:BCr, s : B \to C, then rf=sfr \circ f = s \circ f implies r=sr = s.

Proof.

For the first, compose on the left with f1f^{-1} and use associativity:

g=(f1f)g=f1(fg)=f1(fh)=(f1f)h=h.\begin{aligned} g &= (f^{-1} \circ f) \circ g = f^{-1} \circ (f \circ g) \\ &= f^{-1} \circ (f \circ h) = (f^{-1} \circ f) \circ h = h. \end{aligned}

For the second, compose on the right with f1f^{-1}:

r=r(ff1)=(rf)f1=(sf)f1=s(ff1)=s.\begin{aligned} r &= r \circ (f \circ f^{-1}) = (r \circ f) \circ f^{-1} \\ &= (s \circ f) \circ f^{-1} = s \circ (f \circ f^{-1}) = s. \end{aligned}

Problem 4.21 (Informal).

Let aa and bb be real numbers with a0a \neq 0. Prove that F:RRF : R \to R given by F(x)=defax+bF(x) \defeq ax + b is bijective, and determine F1F^{-1}.

Problem 4.22.

Let f:ABf : A \to B be bijective and let SAS \subset A. Determine the inverse of fS:Sf(S)f|_S : S \to f(S).

Problem 4.23.

Let f:ABf : A \to B and g:BAg : B \to A. Prove that gf=idAg \circ f = \mathrm{id}_A forces ff to be injective and gg to be surjective, while fg=idBf \circ g = \mathrm{id}_B forces ff to be surjective and gg to be injective.

Left and Right Inverses

Definition 4.51 (Left and right inverses).

Let f:ABf : A \to B and g:BAg : B \to A be functions. The function gg is a left inverse of ff if gf=idAg \circ f = \mathrm{id}_A, and a right inverse of ff if fg=idBf \circ g = \mathrm{id}_B. When it is both, it is an inverse in the earlier sense.

The names record the side on which gg sits in the composite. The last problem above gave the two implications that come for free: a left inverse makes ff injective, and a right inverse makes ff surjective. What the two halves achieve together is the next theorem.

Theorem 4.52 (Bijections via one-sided inverses).

Let f:ABf : A \to B be a function. Then ff is bijective if and only if it has both a left inverse and a right inverse; when both exist they coincide, and their common value is f1f^{-1}.

Discussion.

One direction is free: a bijection has f1f^{-1}, which is a left and a right inverse by definition. For the other, the left inverse gives injectivity and the right inverse gives surjectivity, so ff is bijective and f1f^{-1} exists. To identify the one-sided inverses with each other we evaluate the triple composite glfgrg_l \circ f \circ g_r in its two groupings: associativity and the identity laws collapse the middle pair either way, leaving gl=grg_l = g_r. The same calculation with f1f^{-1} in place of either names their common value.

Proof.

Suppose ff has a left inverse glg_l and a right inverse grg_r. If f(x1)=f(x2)f(x_1) = f(x_2), then x1=gl(f(x1))=gl(f(x2))=x2x_1 = g_l(f(x_1)) = g_l(f(x_2)) = x_2, so ff is injective. For yBy \in B, the element gr(y)Ag_r(y) \in A satisfies f(gr(y))=yf(g_r(y)) = y, so ff is surjective. Hence ff is bijective and f1f^{-1} exists by Theorem 4.45 . Associativity and the identity laws give

gl=glidB=gl(fgr)=(glf)gr=idAgr=gr,\begin{aligned} g_l &= g_l \circ \mathrm{id}_B = g_l \circ (f \circ g_r) \\ &= (g_l \circ f) \circ g_r = \mathrm{id}_A \circ g_r = g_r, \end{aligned}

so the two agree; and since f1f^{-1} is itself both a left and a right inverse of ff, the same computation identifies their common value with f1f^{-1}.

Conversely, if ff is bijective then f1f^{-1} is a left and a right inverse by definition.

Theorem 4.53 (Injections and left inverses).

Let AA be non-empty. A function f:ABf : A \to B is injective if and only if it has a left inverse.

Discussion.

If a left inverse exists, injectivity is the implication already noted. For the converse, an injective ff is a bijection onto its range by Proposition 4.38 , so it has an inverse there. On the range a left inverse is forced to be that one, since g(f(x))=xg(f(x)) = x determines gg at every point of f(A)f(A); on the rest of BB we are free, and non-emptiness of AA lets us send all of Bf(A)B \setminus f(A) to one fixed element. That freedom is why left inverses are rarely unique. The hypothesis on AA cannot be dropped: the function from \emptyset to BB is injective, but a function from BB to \emptyset exists only when BB is empty.

Proof.

Suppose first that gf=idAg \circ f = \mathrm{id}_A. If f(x1)=f(x2)f(x_1) = f(x_2), then x1=g(f(x1))=g(f(x2))=x2x_1 = g(f(x_1)) = g(f(x_2)) = x_2, so ff is injective.

Conversely, assume ff is injective. By Proposition 4.38 the function from AA to f(A)f(A) with the same pairs is bijective; let h:f(A)Ah : f(A) \to A be its inverse, which exists by Theorem 4.45 . Fix x0Ax_0 \in A, which we may do since AA is non-empty, and define g:BAg : B \to A by g(y)=defh(y)g(y) \defeq h(y) for yf(A)y \in f(A) and g(y)=defx0g(y) \defeq x_0 for yBf(A)y \in B \setminus f(A). For every xAx \in A the point f(x)f(x) lies in f(A)f(A) and h(f(x))=xh(f(x)) = x, so g(f(x))=xg(f(x)) = x and gf=idAg \circ f = \mathrm{id}_A.

Surjections sit at the other end, and their story is not symmetric. A right inverse forces surjectivity, as we have seen; the converse, that every surjection has a right inverse, is a claim of a different kind. A right inverse must choose, for every yBy \in B at once, one element of f1({y})f^{-1}(\{y\}), and when BB is infinite nothing among our axioms says such a simultaneous choice can be made. That missing licence is the axiom of choice.

Problem 4.24.

Let AA be non-empty and f:ABf : A \to B injective. Show that any two left inverses of ff agree on f(A)f(A). For the inclusion map from {1,2}\{1, 2\} to {1,2,3}\{1, 2, 3\}, exhibit two left inverses and say where they differ.

General Cartesian Products

With functions in hand we can take the product of an arbitrary collection of sets, not just two. First, the informal indexed family of the earlier section can now be said properly.

Remark.

An indexed family {Aα}αI\{A_\alpha\}_{\alpha \in I} of subsets of a set AA is formally a function φ:IP(A)\varphi : I \to \mathcal{P}(A), with Aα=defφ(α)A_\alpha \defeq \varphi(\alpha). It is the function itself, not its range: the range is the plain set of members, which is what the earlier example saw forgetting the labels, while φ\varphi remembers which member sits at which index. Since φ\varphi is a subset of I×P(A)I \times \mathcal{P}(A), it is a set by the axioms of the last chapter, and that is why we ask that all the AαA_\alpha be subsets of one set AA.

Definition 4.54 (General Cartesian product).

Let II be a set and let {Aα}αI\{A_\alpha\}_{\alpha \in I} be an indexed family of sets, all of them subsets of a given set. The Cartesian product of the family is

αIAα=def{fP(I×αIAα)    f is a function, domf=I, αI(f(α)Aα)}.\prod_{\alpha \in I} A_\alpha \defeq \Bigl\{ f \in \mathcal{P}\Bigl(I \times \bigcup_{\alpha \in I} A_\alpha\Bigr) \;\Big|\; f \text{ is a function},\ \operatorname{dom} f = I,\ \forall \alpha \in I\,\bigl(f(\alpha) \in A_\alpha\bigr) \Bigr\}.

The notation is easier to read once we recall that a function from II to αIAα\bigcup_{\alpha \in I} A_\alpha is by Definition 4.15 a subset of I×αIAαI \times \bigcup_{\alpha \in I} A_\alpha. So every candidate lies in the power set displayed above, a set we are already holding, and comprehension carves the product out of it. An element of the product picks one member from each AαA_\alpha, all at once.

Example 4.55.

The definition subsumes the earlier one. A function ff defined on the two-element set {0,1}\{0, 1\} is determined by the pair of values (f(0),f(1))\bigl(f(0), f(1)\bigr), so the functions with f(0)Af(0) \in A and f(1)Bf(1) \in B correspond to the pairs (a,b)(a, b) with aAa \in A and bBb \in B. This identifies A×BA \times B with the general product for I={0,1}I = \{0, 1\}, A0=AA_0 = A and A1=BA_1 = B, and we will not distinguish between the two readings from here on.

Definition 4.56 (Cartesian power).

Let II and AA be sets. The Cartesian power AIA^I is the product of the constant family,

AI=defαIA={fP(I×A)f is a function with domf=I}.A^I \defeq \prod_{\alpha \in I} A = \{f \in \mathcal{P}(I \times A) \mid f \text{ is a function with } \operatorname{dom} f = I\}.

The product of two non-empty sets is non-empty, witnessed by any pair (x,y)(x, y) with xAx \in A and yBy \in B, and the same argument covers three sets, four, and any collection we can write out in full. A perplexing issue arises once II is infinite, where the argument fails for the reason we met in the last chapter: we have no way to string an unspecified number of such choices together. Closing that gap takes another axiom.

The Axiom of Choice

Axiom 4.57 (Choice).

Let II be a non-empty set and let {Aα}αI\{A_\alpha\}_{\alpha \in I} be an indexed family of sets with AαA_\alpha \neq \emptyset for every αI\alpha \in I. Then there exists a function f:IαIAαf : I \to \bigcup_{\alpha \in I} A_\alpha with domf=I\operatorname{dom} f = I and f(α)Aαf(\alpha) \in A_\alpha for every αI\alpha \in I. Equivalently, a non-empty family of non-empty sets has non-empty product.

Such an ff is a choice function for the family. The quantifier order is the whole content: the hypothesis grants each set an element of its own, while the conclusion assembles one selection from every set into a single function.

Remark.

The axiom is independent of the others, in the sense that neither it nor its negation follows from them. In sets carrying some structure a distinguished element can often be picked out constructively, and no axiom is needed; the axiom supplies one in full generality, where no rule for choosing is available. Mathematicians find it rather less comfortable than the rest, so it is good practice, which we will follow, to say plainly whenever it is used.

Theorem 4.58 (Every surjection has a right inverse).

Let f:ABf : A \to B be surjective. Then ff has a right inverse g:BAg : B \to A.

Discussion.

Surjectivity says, through Proposition 4.31 , that every point preimage f1({y})f^{-1}(\{y\}) is non-empty. That is exactly the hypothesis of the axiom of choice applied to the family of point preimages indexed by BB, and what the axiom returns is a function φ\varphi picking one element out of each. The union of the point preimages is AA, and φ(y)f1({y})\varphi(y) \in f^{-1}(\{y\}) says precisely that f(φ(y))=yf(\varphi(y)) = y, which is the right-inverse identity. The axiom is doing real work: each preimage alone has an element, and the theorem needs one choice per preimage assembled into a single map.

Proof.

If BB is empty then so is AA, since every element of AA would have an image in BB, and the empty function is a right inverse; so assume BB is non-empty. For every yBy \in B the set f1({y})f^{-1}(\{y\}) is non-empty by Proposition 4.31 . Applying the axiom of choice to the family {f1({y})}yB\{f^{-1}(\{y\})\}_{y \in B} gives a function φ\varphi from BB to yBf1({y})\bigcup_{y \in B} f^{-1}(\{y\}) with φ(y)f1({y})\varphi(y) \in f^{-1}(\{y\}) for every yBy \in B. Each point preimage is a subset of AA, so that union is AA and φ:BA\varphi : B \to A. Finally φ(y)f1({y})\varphi(y) \in f^{-1}(\{y\}) is equivalent to f(φ(y))=yf(\varphi(y)) = y, so fφ=idBf \circ \varphi = \mathrm{id}_B and φ\varphi is a right inverse of ff.

Corollary 4.59 (Surjections and right inverses).

A function f:ABf : A \to B is surjective if and only if it has a right inverse.

Proof.

One direction is the theorem. For the other, a right inverse gg gives f(g(y))=yf(g(y)) = y for every yBy \in B, so g(y)g(y) is a preimage of yy and ff is surjective.

Problem 4.25.

Let I={1,2,3}I = \{1, 2, 3\} and let {Mi}iI\{M_i\}_{i \in I} be a family of non-empty sets. Show that iIMi\prod_{i \in I} M_i is non-empty without appealing to the axiom of choice. Where would the argument break down for an index set that cannot be written out in full?

Exercises

 

Answers are checked in your browser, as often as you like. Nothing is sent anywhere and nothing is kept but your own work. A formula may be written with the symbols themselves or with ~ & | -> <-> ^, and \and, \or, \to expand as you type.

Exercise 4.1.

Let S={0,1}S = \{0, 1\} and T={1,2}T = \{1, 2\}.

The only pair belonging to both S×TS \times T and T×ST \times S is:

answer one of these

(ST)×(ST)(S \cap T) \times (S \cup T) is:

answer one of these

Exercise 4.2.

Write aa and bb for the statements xAx \in A and xBx \in B, and cc and dd for yCy \in C and yDy \in D. Give the condition on the pair (x,y)(x, y) for membership in each set below.

(AB)×(CD)(A \cup B) \times (C \cup D)

answer formula

(A×C)(B×D)(A \times C) \cup (B \times D)

answer formula

The two sets are different. Place one pair (x,y)(x, y) that separates them.

answer assignment
a b c d

Which two products does the second set leave out?

answer one of these

Now the condition of the first part again, written as a disjunction of conjunctions.

answer formula

Exercise 4.3.

Let A1={1,2,3,4}A_1 = \{1, 2, 3, 4\}, A2={0,1,2}A_2 = \{0, 1, 2\} and A3={1,0,1}A_3 = \{-1, 0, 1\}, with I={1,2,3}I = \{1, 2, 3\}, and take U={1,0,1,2,3,4,5}U = \{-1, 0, 1, 2, 3, 4, 5\} as the ambient set.

iIAi\bigcup_{i \in I} \overline{A_i} is:

answer one of these

iIAi\bigcap_{i \in I} \overline{A_i} is:

answer one of these

Exercise 4.4.

Let nn be a positive whole number, let I={1,2,,n}I = \{1, 2, \ldots, n\}, and let {Ai}iI\{A_i\}_{i \in I} be a family with AiAjA_i \subset A_j whenever iji \leqslant j.

iIAi\bigcup_{i \in I} A_i and iIAi\bigcap_{i \in I} A_i are:

answer one of these

Exercise 4.5.

A family {Ai}iI\{A_i\}_{i \in I} is disjoint if iIAi=\bigcap_{i \in I} A_i = \emptyset, and pairwise disjoint if AiAj=A_i \cap A_j = \emptyset whenever iji \neq j.

The family A1={1,2,3,4}A_1 = \{1, 2, 3, 4\}, A2={3,4,5,6}A_2 = \{3, 4, 5, 6\}, A3={1,6,7}A_3 = \{1, 6, 7\} is:

answer one of these

For families {B1,B2,B3}\{B_1, B_2, B_3\} of three sets:

answer one of these

Exercise 4.6.

Counting.

SS and TT each have three elements. The number of functions from SS to TT is:

answer one of these

SS has three elements and TT has two. The number of injections from SS to TT is:

answer one of these

And the number of surjections from SS to TT is:

answer one of these

With those same SS and TT, the number of injections from TT to SS is:

answer one of these

Exercise 4.7.

Cartesian powers.

The number of elements of {1,2}{1,2}\{1, 2\}^{\{1, 2\}} is:

answer one of these

For every non-empty set AA, the power A\emptyset^A is:

answer one of these

For every set BB, the power BB^{\emptyset} is:

answer one of these

Exercise 4.8.

Take the real numbers on trust and let q:RRq : R \to R be given by q(x)=defx2q(x) \defeq x^2.

q({2,1,0,1})q(\{-2, -1, 0, 1\}) is:

answer one of these

q1({1,4})q^{-1}(\{1, 4\}) is:

answer one of these

q1(q({0,1}))q^{-1}\bigl(q(\{0, 1\})\bigr) is:

answer one of these

A function f:ABf : A \to B satisfies f1(f(S))=Sf^{-1}(f(S)) = S for every SAS \subset A exactly when it is:

answer one of these

And f(f1(U))=Uf(f^{-1}(U)) = U holds for every UBU \subset B exactly when ff is:

answer one of these

Exercise 4.9.

Injective, surjective, both or neither.

g:{1,2,3}{2,5,6}g : \{1, 2, 3\} \to \{-2, 5, 6\} given by g=def{(1,5),(2,2),(3,6)}g \defeq \{(1, 5), (2, -2), (3, 6)\} is:

answer one of these

h:{1,2,3}{2,5,6}h : \{1, 2, 3\} \to \{-2, 5, 6\} given by h=def{(3,5),(2,2),(1,5)}h \defeq \{(3, 5), (2, -2), (1, 5)\} is:

answer one of these

The inclusion map ι:ST\iota : S \to T of a set SS with STS \subsetneq T is:

answer one of these

A constant map c:ABc : A \to B, where AA and BB both have at least two elements, is:

answer one of these

The function from \emptyset to a non-empty BB is:

answer one of these

Exercise 4.10.

Keeping the real numbers, let qq, τ\tau and NN be the maps RRR \to R given by q(x)=defx2q(x) \defeq x^2, τ(x)=defx+1\tau(x) \defeq x + 1 and N(x)=defxN(x) \defeq |x|, where x|x| is xx when x0x \geqslant 0 and x-x otherwise.

The function xx+1x \mapsto |x + 1| is:

answer one of these

The composites NqN \circ q and qNq \circ N are:

answer one of these

The function x((x+1)2+1)2x \mapsto \bigl((x + 1)^2 + 1\bigr)^2 is:

answer one of these

Exercise 4.11.

Inverses, one-sided and two-sided.

Let f:ABf : A \to B and g:BCg : B \to C be bijections. The composite g1f1g^{-1} \circ f^{-1} is defined:

answer one of these

A function with a left inverse but no right inverse is:

answer one of these

The statement that cannot be proved without the axiom of choice is:

answer one of these

Exercises in Lean

 

The proofs below are checked in your browser. Nothing is sent anywhere, and nothing is stored but your own work. Type \to for →, \and for ∧, \< and \> for ⟨ ⟩.

The last sheet gave the checker a universe of objects and the algebra of sets. This one adds the constructions of this chapter: the ordered pair, the product, the indexed family and the map.

A pair is typed as it is written, (a, b), and longer tuples nest to the left exactly as Definition 4.4 says, so (a, b, c) is ((a, b), c). The product is ×, typed \x, and it binds like . A map is written f : Obj → Obj and applied by juxtaposition, f x; the domain and codomain of Definition 4.15 are carried by the statement being proved rather than by the arrow.

Ordered pairs

The pair itself is opaque: the checker knows nothing about {{a},{a,b}}\bigl\{\{a\}, \{a, b\}\bigr\}, only what Proposition 4.2 established about it. That proposition is Set.pair_eq, a biconditional, so .mp reads coordinates off an equality of pairs and .mpr builds one.

Example.

The forward direction turns the equality into a conjunction; the first half of it is the first coordinate.

lean worked
1example (a b c d : Obj) (h : (a, b) = (c, d)) : a = c := by
verified
goalGoals accomplished.

Exercise 4.12.

Corollary 4.3 , in one direction.

lean proof
1example (a b : Obj) : (a, b) = (b, a)  a = b := by
goala b : Obj (a, b) = (b, a) a = b

Exercise 4.13.

Coordinates read off one pair and put back into another.

lean proof
1example (a b c d : Obj) : (a, b) = (c, d)  (b, a) = (d, c) := by
goala b c d : Obj (a, b) = (c, d) (b, a) = (d, c)

Exercise 4.14.

A triple is a pair of a pair, so its middle coordinate takes two steps to reach.

lean proof
1example (a b c x y z : Obj) : (a, b, c) = (x, y, z)  b = y := by
goala b c x y z : Obj ((a, b), c) = ((x, y), z) b = y

Products

Membership in a product is the dictionary line of the chapter: (x, y) ∈ A × B is x ∈ A ∧ y ∈ B, in the way that x ∈ A ∩ B was a conjunction on the last sheet, so ⟨_, _⟩ builds one and .left and .right take one apart.

Example.

Two memberships, one pair.

lean worked
1example (A B x y : Obj) (hx : x  A) (hy : y  B) : (x, y)  A × B := by
verified
goalGoals accomplished.

An arbitrary object is not written as a pair, and for it the criterion says the rest of Definition 4.6 : p ∈ A × B is

∃ a, ∃ b, p = (a, b) ∧ a ∈ A ∧ b ∈ B

so a membership hypothesis about an unknown pp hands over two coordinates, an equation and two memberships. obtain takes all five at once, and the equation is what rw then uses to turn pp into a pair everywhere it is needed.

Example.

Once pp has been rewritten, the goal is about a pair and the criterion applies to it.

lean worked
1example (A B C p : Obj) (h : p  A × B) (hbc : B  C) : p  A × C := by
verified
goalGoals accomplished.

Exercise 4.15.

The coordinates change places and so do the factors.

lean proof
1example (A B x y : Obj) : (x, y)  A × B  (y, x)  B × A := by
goalA B x y : Obj (x, y) A × B (y, x) B × A

Exercise 4.16.

Nothing can serve as a second coordinate.

lean proof
1example (A : Obj) : A ×  =  := by
goalA : Obj A × =

Exercise 4.17.

The product respects inclusion in each factor.

lean proof
1example (A B C D : Obj) : A  B  C  D  A × C  B × D := by
goalA B C D : Obj A B C D A × C B × D

Exercise 4.18.

Products distribute over intersections.

lean proof
1example (A B C : Obj) : A × (B  C) = (A × B)  (A × C) := by
goalA B C : Obj A × (B C) = (A × B) (A × C)

Exercise 4.19.

And over unions.

lean proof
1example (A B C : Obj) : A × (B  C) = (A × B)  (A × C) := by
goalA B C : Obj A × (B C) = A × B A × C

Exercise 4.20.

An intersection of products is a product of intersections.

lean proof
1example (A B C D : Obj) : (A × B)  (C × D) = (A  C) × (B  D) := by
goalA B C D : Obj (A × B) (C × D) = (A C) × (B D)

Exercise 4.21.

The inclusion that never fails.

lean proof
1example (A B C D : Obj) : (A × C)  (B × D)  (A  B) × (C  D) := by
goalA B C D : Obj A × C B × D (A B) × (C D)

Exercise 4.22.

The equality the last exercise fell short of, with the two mixed products restored.

lean proof
1example (A B C D : Obj) :2    (A  B) × (C  D) = ((A × C)  (A × D))  ((B × C)  (B × D)) := by
goalA B C D : Obj (A B) × (C D) = (A × C A × D) (B × C B × D)

Indexed families

A family {Bi}iI\{B_i\}_{i \in I} is a map from indices to sets, written B : Obj → Obj, and its union and intersection are ⋃ i ∈ I, B i and ⋂ i ∈ I, B i, typed \bigcup and \bigcap. Their criteria are the two the chapter gave: membership in the union is ∃ i, i ∈ I ∧ x ∈ B i, and membership in the intersection is ∀ i, i ∈ I → x ∈ B i. So an intersection is used by applying it to an index and a proof that the index belongs to II, and a union is built with use.

Example.

The intersection applied at one index.

lean worked
1example (I k : Obj) (B : Obj  Obj) (hk : k  I) : ( i  I, B i)  B k := by
verified
goalGoals accomplished.

Example.

use supplies the index; what remains is that the index is one of ours and that xx lies in its set.

lean worked
1example (I k : Obj) (B : Obj  Obj) (hk : k  I) : B k   i  I, B i := by
verified
goalGoals accomplished.

An object kept out of an intersection is refused by some one set, but the index doing the refusing is not handed to us: all we hold is that no index can be a witness. Getting the index out is the classical step, and by_contra twice is what does it.

Example.

The first by_contra denies the index we want; the second turns that denial into membership at every index, which is what the hypothesis refuses.

lean worked
1example (I x : Obj) (B : Obj  Obj) (h : x   i  I, B i) :2     i : Obj, i  I  x  B i := by
verified
goalGoals accomplished.

Exercise 4.23.

A set lies inside the intersection exactly when it lies inside every member.

lean proof
1example (I A : Obj) (B : Obj  Obj) :2    A  ( i  I, B i)   i : Obj, i  I  A  B i := by
goalI A : Obj B : Obj Obj A ( i I, B i) ( (i : Obj), i I A B i)

Exercise 4.24.

And the union lies inside a set exactly when every member does.

lean proof
1example (I A : Obj) (B : Obj  Obj) :2    ( i  I, B i)  A   i : Obj, i  I  B i  A := by
goalI A : Obj B : Obj Obj ( i I, B i) A ( (i : Obj), i I B i A)

Exercise 4.25.

The first part of Proposition 4.13 .

lean proof
1example (I A : Obj) (B : Obj  Obj) :2    A \ ( i  I, B i) =  i  I, (A \ B i) := by
goalI A : Obj B : Obj Obj A \ ( i I, B i) = ( i I, A \ B i)

Exercise 4.26.

The second part. The hypothesis hj is the non-emptiness of II, and one of the two inclusions cannot be had without it.

lean proof
1example (I A j : Obj) (B : Obj  Obj) (hj : j  I) :2    A \ ( i  I, B i) =  i  I, (A \ B i) := by
goalI A j : Obj B : Obj Obj hj : j I A \ ( i I, B i) = ( i I, A \ B i)

Exercise 4.27.

The inclusion between the two mixed families, in the direction that holds.

lean proof
1example (I J : Obj) (A : Obj  Obj  Obj) :2    ( i  I,  j  J, A i j)  ( j  J,  i  I, A i j) := by
goalI J : Obj A : Obj Obj Obj ( i I, j J, A i j) ( j J, i I, A i j)

Maps

For a map f : Obj → Obj, the image and preimage of a set are f '' S and f ⁻¹' U, typed as two apostrophes and as \preimage. Their criteria are those of Definition 4.23 and Definition 4.24 : y ∈ f '' S is ∃ x, x ∈ S ∧ f x = y, and x ∈ f ⁻¹' U is f x ∈ U. Composition is g ∘ f, typed \o, and (g ∘ f) x is g (f x). Finally Injective f and Surjective f are the two conditions of Definition 4.30 and Definition 4.28 , ∀ x y, f x = f y → x = y and ∀ y, ∃ x, f x = y, so both are opened with intro.

Example.

The witness is the point itself, and the equation it has to satisfy is an identity.

lean worked
1example (f : Obj  Obj) (S x : Obj) (hx : x  S) : f x  f '' S := by
verified
goalGoals accomplished.

The preimage passes membership straight through to fxf x, and that is the whole of why it preserves the operations: both sides of each law are the same statement about fxf x.

Example.

Part three of Proposition 4.27 , which the criterion settles outright.

lean worked
1example (f : Obj  Obj) (U V : Obj) : f ⁻¹' (U  V) = f ⁻¹' U  f ⁻¹' V := by
verified
goalGoals accomplished.

Exercise 4.28.

Images preserve unions.

lean proof
1example (f : Obj  Obj) (S T : Obj) : f '' (S  T) = f '' S  f '' T := by
goalf : Obj Obj S T : Obj f '' (S T) = f '' S f '' T

Exercise 4.29.

Every point of SS is sent into the image of SS.

lean proof
1example (f : Obj  Obj) (S : Obj) : S  f ⁻¹' (f '' S) := by
goalf : Obj Obj S : Obj S f ⁻¹' (f '' S)

Exercise 4.30.

And the image of a preimage is no bigger than the set it came from.

lean proof
1example (f : Obj  Obj) (U : Obj) : f '' (f ⁻¹' U)  U := by
goalf : Obj Obj U : Obj f '' (f ⁻¹' U) U

Exercise 4.31.

The first part of Theorem 4.43 .

lean proof
1example (f g : Obj  Obj) :2    Injective f  Injective g  Injective (g  f) := by
goalf g : Obj Obj Injective f Injective g Injective (g f)

Exercise 4.32.

Its second part.

lean proof
1example (f g : Obj  Obj) :2    Surjective f  Surjective g  Surjective (g  f) := by
goalf g : Obj Obj Surjective f Surjective g Surjective (g f)

Exercise 4.33.

Only the first map need be injective for the composite to be.

lean proof
1example (f g : Obj  Obj) : Injective (g  f)  Injective f := by
goalf g : Obj Obj Injective (g f) Injective f

Exercise 4.34.

And only the second need be surjective.

lean proof
1example (f g : Obj  Obj) : Surjective (g  f)  Surjective g := by
goalf g : Obj Obj Surjective (g f) Surjective g

Exercise 4.35.

A left inverse, written out pointwise, makes ff injective.

lean proof
1example (f g : Obj  Obj) : ( x : Obj, g (f x) = x)  Injective f := by
goalf g : Obj Obj ( (x : Obj), g (f x) = x) Injective f

Exercise 4.36.

A right inverse makes it surjective.

lean proof
1example (f g : Obj  Obj) : ( y : Obj, f (g y) = y)  Surjective f := by
goalf g : Obj Obj ( (y : Obj), f (g y) = y) Surjective f

Exercise 4.37.

Images preserve intersections when, and only when, nothing is glued together on the way.

lean proof
1example (f : Obj  Obj) (S T : Obj) :2    Injective f  f '' (S  T) = f '' S  f '' T := by
goalf : Obj Obj S T : Obj Injective f f '' (S T) = f '' S f '' T

Exercise 4.38.

The inclusion two exercises above becomes an equality for an injective map.

lean proof
1example (f : Obj  Obj) (S : Obj) : Injective f  f ⁻¹' (f '' S) = S := by
goalf : Obj Obj S : Obj Injective f f ⁻¹' (f '' S) = S
What the checker understands

Tactics

intro h assume the hypothesis of an implication, naming it h
exact e give the proof outright
apply f reduce the goal to the hypotheses of f
assumption close the goal with a hypothesis already present
trivial close the goal True
exfalso replace the goal with False
by_contra h assume the negation of the goal
constructor split ∧ into both halves, or ↔ into both directions
left / right choose which half of a ∨ to prove
rcases h with a | b argue by cases on a disjunction
obtain a, b := h take a conjunction or an existential apart
cases h as above, keeping the name
refine e give the proof with holes left in it
have h : p := record an intermediate result
show p restate the goal in an equal form
use w give a witness for ∃
specialize h a instantiate a ∀ hypothesis
rw [h] rewrite with an equation, ← to go backwards
rfl both sides compute to the same thing
decide / norm_num settle a closed computation
tauto close a goal that is true by pure logic

Results you may cite

Classical.em (a : Prop), a ¬a — the law of excluded middle
Classical.byContradiction {a : Prop}, (¬a False) a — proof by contradiction; the tactic by_contra does this for you
Classical.byCases {a b : Prop}, (a b) (¬a b) b — split on whether a holds
not_not {a : Prop}, ¬¬a a — double negation
not_and_or {a b : Prop}, ¬(a b) ¬a ¬b — De Morgan
not_or {a b : Prop}, ¬(a b) ¬a ¬b — De Morgan
not_imp {a b : Prop}, ¬(a b) a ¬b
and_comm {a b : Prop}, a b b a
or_comm {a b : Prop}, a b b a
Set.ext {A B : Obj}, ( x : Obj, x A x B) A = B — extensionality: sets with the same elements are equal
Set.ext_iff {A B : Obj}, A = B ( x : Obj, x A x B) — extensionality and substitution, in one biconditional
Set.subset_antisymm {A B : Obj}, A B B A A = B — mutual inclusion is equality
Set.empty_subset {A : Obj}, A — the empty set is a subset of every set
Set.pair_eq {a b c d : Obj}, ((a, b) = (c, d)) (a = c b = d) — two ordered pairs are equal exactly when their coordinates are

From the logical core

And.intro {a b : Prop}, a b a b
And.left {a b : Prop}, a b a
And.right {a b : Prop}, a b b
And.symm {a b : Prop}, a b b a
Or.inl {a b : Prop}, a a b
Or.inr {a b : Prop}, b a b
Or.elim {a b c : Prop}, a b (a c) (b c) c
Or.symm {a b : Prop}, a b b a
Iff.intro {a b : Prop}, (a b) (b a) (a b)
Iff.mp {a b : Prop}, (a b) a b
Iff.mpr {a b : Prop}, (a b) b a
Iff.symm {a b : Prop}, (a b) (b a)
Iff.rfl {a : Prop}, a a
Iff.trans {a b c : Prop}, (a b) (b c) (a c)
True.intro True
False.elim {a : Prop}, False a
absurd {a b : Prop}, a ¬a b
id {a : Prop}, a a
mt {a b : Prop}, (a b) ¬b ¬a
Eq.refl {α : Type} (a : α), a = a
Eq.symm {α : Type} {a b : α}, a = b b = a
Eq.trans {α : Type} {a b c : α}, a = b b = c a = c
congrArg {α : Type} {β : Type} {a b : α} (f : α β), a = b f a = f b
Exists.intro {α : Type} {p : α Prop} (w : α), p w x : α, p x
Exists.elim {α : Type} {p : α Prop} {b : Prop}, ( x : α, p x) ( y : α, p y b) b