BACK 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 a≠ba \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=c∧b=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 a≠ba \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 a≠ba \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 a≠ba \neq b; therefore {a,b}={c,d}\{a, b\} = \{c, d\}. It follows that b=cb = c or b=db = d; but c=a≠bc = a \neq b, so b≠cb \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=c∧a=d)∧(a=c∧b=c))∨(a=c∧((a=c∧b=d)∨(a=d∧b=c)))≡(a=c∧a=d∧b=c)∨(a=c∧b=d)∨(a=c∧a=d∧b=c)≡(a=c∧a=d∧b=c)∨(a=c∧b=d)≡(a=c∧a=d∧b=c∧b=d)∨(a=c∧b=d)≡a=c∧b=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 possible choice, and the next problem looks at a shorter one.

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 a∈Aa \in A and b∈Bb \in B. Then (a,b)∈P(P(A∪B))(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 A∪BA \cup B. We go up one power set at a time: show each of {a}\{a\} and {a,b}\{a, b\} is a subset of A∪BA \cup B, which puts both in P(A∪B)\mathcal{P}(A \cup B), and then that having both as elements makes (a,b)(a, b) a subset of P(A∪B)\mathcal{P}(A \cup B), which is what membership in the next power set asks for.

Proof.

Since a∈Aa \in A we have a∈A∪Ba \in A \cup B, and since b∈Bb \in B we have b∈A∪Bb \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}⊂A∪B\{a\} \subset A \cup B and {a,b}⊂A∪B\{a, b\} \subset A \cup B, that is, both belong to P(A∪B)\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(A∪B)(a, b) \subset \mathcal{P}(A \cup B), which is (a,b)∈P(P(A∪B))(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  {p∈P(P(A∪B))  ∣  ∃a∈A ∃b∈B (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, p∈A×Bp \in A \times B exactly when p=(a,b)p = (a, b) for some a∈Aa \in A and some b∈Bb \in B.

The product needs no axiom of its own. The proposition above puts every candidate pair inside P(P(A∪B))\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)≡(s∈S)∧(t∈T).\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×T≠T×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 1∉T1 \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×∅)≡(s∈S)∧⊥≡⊥\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 s∈Ss \in S, t∈Tt \in T and r∈Rr \in R, and so on upwards. There is a subtlety here.

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×T≠T×SS \times T \neq T \times S in general. Find every case in which they are equal.

Indexed Families

It is often convenient to give each set in a collection a label.

Definition 4.10 (Indexed family).

Let II be a set. An indexed family consists of one object xix_i for each i∈Ii \in I, and is written {xi}i∈I\{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}i∈I\{B_i\}_{i \in I} has four entries, and the equality B1=B3B_1 = B_3 removes neither of them: the labels 11 and 33 are different even though the sets they label are equal. 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 records more than the plain set of members {A,C,D}\{A, C, D\}, which does not record that AA occurs twice.

Definition 4.12 (Indexed unions and intersections).

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

⋃i∈IAi=def⋃{Ai:i∈I},⋂i∈IAi=def{x∈⋃i∈IAi  ∣  ∀i∈I (x∈Ai)},\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 x∈⋃i∈IAix \in \bigcup_{i \in I} A_i exactly when x∈Aix \in A_i for some i∈Ii \in I, and x∈⋂i∈IAix \in \bigcap_{i \in I} A_i exactly when x∈Aix \in A_i for every i∈Ii \in I.

Neither needs an axiom beyond those we have. Replacement turns the index set into the set {Ai:i∈I}\{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 ((i∈I)∧(x∈Ai))\exists i\,\bigl((i \in I) \land (x \in A_i)\bigr) for the union and ∀i ((i∈I)  ⟹  (x∈Ai))\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, ⋃i∈IAi=A1∪A2\bigcup_{i \in I} A_i = A_1 \cup A_2 and ⋂i∈IAi=A1∩A2\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:

x∉⋂i∈IAi  ⟺  ∃i∈I (x∉Ai),x∉⋃i∈IAi  ⟺  ∀i∈I (x∉Ai).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).

So xx is outside the intersection if it misses a single AiA_i, but outside the union only if it misses every AiA_i.

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 i⩽m⩽2ii \leqslant m \leqslant 2i. Determine ⋃i∈IAi\bigcup_{i \in I} A_i and ⋂i∈IAi\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

P∧∃i∈I Q(i)≡∃i∈I (P∧Q(i)),P∧∀i∈I Q(i)≡∀i∈I (P∧Q(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}i∈I\{B_i\}_{i \in I} be an indexed family of sets with II non-empty. Then

  1. A∖⋂i∈IBi=⋃i∈I(A∖Bi)A \setminus \bigcap_{i \in I} B_i = \bigcup_{i \in I} (A \setminus B_i);
  2. A∖⋃i∈IBi=⋂i∈I(A∖Bi)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 A∖⋂i∈IBiA \setminus \bigcap_{i \in I} B_i sits in AA and misses some BjB_j, so it sits in A∖BjA \setminus B_j and hence in the union of the differences; conversely, belonging to one difference A∖BjA \setminus B_j already keeps the element out of the intersection. The second identity is the same argument 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 x∈Ax \in A through the quantifier.

Proof (element style).

For the first, suppose x∈A∖⋂i∈IBix \in A \setminus \bigcap_{i \in I} B_i. Then x∈Ax \in A, but xx does not belong to every BiB_i, so x∉Bjx \notin B_j for some j∈Ij \in I. Hence x∈A∖Bjx \in A \setminus B_j, and therefore x∈⋃i∈I(A∖Bi)x \in \bigcup_{i \in I} (A \setminus B_i). Conversely, suppose xx belongs to that union. Then for some j∈Ij \in I we have x∈A∖Bjx \in A \setminus B_j, so x∈Ax \in A and x∉Bjx \notin B_j. It follows that x∉⋂i∈IBix \notin \bigcap_{i \in I} B_i, whence x∈A∖⋂i∈IBix \in A \setminus \bigcap_{i \in I} B_i.

For the second, suppose x∈A∖⋃i∈IBix \in A \setminus \bigcup_{i \in I} B_i. Then x∈Ax \in A and x∉Bix \notin B_i for every i∈Ii \in I, so x∈A∖Bix \in A \setminus B_i for every i∈Ii \in I, that is, x∈⋂i∈I(A∖Bi)x \in \bigcap_{i \in I} (A \setminus B_i). Conversely, membership in that intersection gives x∈A∖Bix \in A \setminus B_i for every i∈Ii \in I, so x∈Ax \in A and no BiB_i holds xx, which puts xx in A∖⋃i∈IBiA \setminus \bigcup_{i \in I} B_i.

Proof (logical style).

For any xx,

x∈A∖⋂i∈IBi≡(x∈A)∧¬ ∀i∈I (x∈Bi)by the definitions≡(x∈A)∧∃i∈I (x∉Bi)by quantifier negation≡∃i∈I ((x∈A)∧(x∉Bi))by the exchange law≡x∈⋃i∈I(A∖Bi)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

x∈A∖⋃i∈IBi≡(x∈A)∧¬ ∃i∈I (x∈Bi)by the definitions≡(x∈A)∧∀i∈I (x∉Bi)by quantifier negation≡∀i∈I ((x∈A)∧(x∉Bi))by the exchange law≡x∈⋂i∈I(A∖Bi)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}i∈I\{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,

⋂i∈IBi‾=⋃i∈IBi‾,⋃i∈IBi‾=⋂i∈IBi‾.\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 U∖BiU \setminus B_i is the complement Bi‾\overline{B_i}, and the identities follow.

Problem 4.6.

Let AA be a set and {Bi}i∈I\{B_i\}_{i \in I} an indexed family of sets with II non-empty. Prove that A⊂⋂i∈IBiA \subset \bigcap_{i \in I} B_i if and only if A⊂BiA \subset B_i for every i∈Ii \in I, and that ⋃i∈IBi⊂A\bigcup_{i \in I} B_i \subset A if and only if Bi⊂AB_i \subset A for every i∈Ii \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

⋃i∈I⋂j∈JAi,jand⋂j∈J⋃i∈IAi,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:X→Yf : 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 f⊂X×Yf \subset X \times Y such that for every x∈Xx \in X there is exactly one y∈Yy \in Y with (x,y)∈f(x, y) \in f. We write f:X→Yf : X \to Y, call XX the domain of ff, written dom⁡f\operatorname{dom} f, and YY the codomain, and write f(x)f(x) for the unique yy paired with xx, so that for any x∈Xx \in X and y∈Yy \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 x↦f(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 x∈Xx \in X and y∈Yy \in Y, and suppose that for every x∈Xx \in X there is exactly one y∈Yy \in Y making P(x,y)P(x, y) true. Then

f  =def  {p∈X×Y  ∣  ∃x∈X ∃y∈Y (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 x≠0x \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=x′x = 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 x′x' 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 S⊂TS \subset T. The inclusion map ι:S→T\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 b0∈Bb_0 \in B, the constant map with value b0b_0 is c:A→Bc : A \to B given by c(a)=defb0c(a) \defeq b_0 for every a∈Aa \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. 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 f⊂A×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. Drawn this way, 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 f⊂gf \subset g. A symmetric argument gives g⊂fg \subset f, so f=gf = g.

Proof (logical style).

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

x∈dom⁡f≡∃y ((x,y)∈f)≡∃y ((x,y)∈g)≡x∈dom⁡g,\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≡(x∈dom⁡f)∧(y=f(x))≡(x∈dom⁡g)∧(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)∣x∈S}\{(x, x) \mid x \in S\} defines the identity map idS:S→S\mathrm{id}_S : S \to S, but for any TT with S⊂TS \subset T it equally defines the inclusion map ι:S→T\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:B→Cg : B \to C be a function and let A⊂BA \subset B. The restriction of gg to AA is the function g∣A:A→Cg|_A : A \to C given by g∣A(x)=defg(x)g|_A(x) \defeq g(x). The function gg is called an extension of g∣Ag|_A to BB.

Example 4.22 (Informal).

Consider

f:W→R,f(x)=defx2−1,g:R→R,g(x)=defx2−1,h:R→R,h(x)=def(x−1)(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 (x−1)(x+1)=x2−1(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=g∣W=h∣Wf = 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:X→Yf : 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 G⊂X×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:X→Yf : X \to Y be a function and define its graph to be the subset {(x,f(x))∣x∈X}\{(x, f(x)) \mid x \in X\} of X×YX \times Y.

  1. Show that two functions f,f~:X→Yf, \tilde{f} : X \to Y are equal if and only if they have the same graph.
  2. Conversely, let G⊂X×YG \subset X \times Y be such that for each x∈Xx \in X the set {y∈Y∣(x,y)∈G}\{y \in Y \mid (x, y) \in G\} has exactly one element. Show that there is exactly one function f:X→Yf : 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 G⊂X×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:A→Bf : A \to B be a function and let S⊂AS \subset A. The image of SS under ff is f(S)=def{f(x)∣x∈S}f(S) \defeq \{f(x) \mid x \in S\}. The image of the whole domain is the range of ff, written im⁡f=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 ,

im⁡f={y∈B  ∣  ∃x∈A ((x,y)∈f)}={y∈B  ∣  ∃x∈A (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:A→Bf : A \to B be a function and let U⊂BU \subset B. The preimage of UU under ff is f−1(U)=def{x∈A∣f(x)∈U}f^{-1}(U) \defeq \{x \in A \mid f(x) \in U\}. In particular f−1({y})={x∈A∣f(x)=y}f^{-1}(\{y\}) = \{x \in A \mid f(x) = y\} is the set of all preimages of y∈By \in B.

The notation f−1(U)f^{-1}(U) does not assume that ff has an inverse function; the definition applies to every function. The set f−1({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:A→Bf : 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 im⁡f={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 f−1({y})f^{-1}(\{y\}) is non-empty exactly when y∈im⁡fy \in \operatorname{im} f, and how many elements it holds records how many inputs are sent to yy. Here f−1({s})={2,3}f^{-1}(\{s\}) = \{2, 3\}, f−1({r,t})={1,4}f^{-1}(\{r, t\}) = \{1, 4\} and f−1({u})=∅f^{-1}(\{u\}) = \emptyset.

Example 4.26 (Informal).

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

Proposition 4.27 (Set laws for preimages).

Let f:A→Bf : A \to B be a function and let U,V⊂BU, V \subset B. Then

  1. f−1(B∖U)=A∖f−1(U)f^{-1}(B \setminus U) = A \setminus f^{-1}(U);
  2. f−1(U∪V)=f−1(U)∪f−1(V)f^{-1}(U \cup V) = f^{-1}(U) \cup f^{-1}(V);
  3. f−1(U∩V)=f−1(U)∩f−1(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 x∈Ax \in A and that its image has the required property. So f(x)∈B∖Uf(x) \in B \setminus U says precisely that f(x)∉Uf(x) \notin U; membership in U∪VU \cup V means membership in at least one of UU and VV; and membership in U∩VU \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 x∈f−1(B∖U)x \in f^{-1}(B \setminus U), then x∈Ax \in A and f(x)∉Uf(x) \notin U, so x∈A∖f−1(U)x \in A \setminus f^{-1}(U). Conversely, if x∈A∖f−1(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)∈B∖Uf(x) \in B \setminus U, whence x∈f−1(B∖U)x \in f^{-1}(B \setminus U).

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

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

Proof (logical style).

For every xx,

x∈f−1(B∖U)≡(x∈A)∧(f(x)∉U)≡x∈A∖f−1(U),x∈f−1(U∪V)≡(x∈A)∧((f(x)∈U)∨(f(x)∈V))≡(x∈f−1(U))∨(x∈f−1(V))≡x∈f−1(U)∪f−1(V),x∈f−1(U∩V)≡(x∈A)∧((f(x)∈U)∧(f(x)∈V))≡(x∈f−1(U))∧(x∈f−1(V))≡x∈f−1(U)∩f−1(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 x∈Ax \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 S↦f(S)S \mapsto f(S) and U↦f−1(U)U \mapsto f^{-1}(U), a function f:A→Bf : 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 f−1f^{-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\}), f−1({r,s})f^{-1}(\{r, s\}) and f−1({s,u})f^{-1}(\{s, u\}).

Problem 4.13.

Let f:A→Bf : A \to B be a function and let S,T⊂AS, T \subset A. Prove that f(S∪T)=f(S)∪f(T)f(S \cup T) = f(S) \cup f(T). Must f(S∩T)=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:A→Bf : A \to B is surjective, or onto BB, if f(A)=Bf(A) = B; equivalently, if for every y∈By \in B there is some x∈Ax \in A with f(x)=yf(x) = y.

Every function is surjective onto its range.

Example 4.29 (Informal).

The successor map s:W→Ws : 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:A→Bf : A \to B is injective, or one-to-one, if for all x1,x2∈Ax_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:A→Bf : A \to B be a function.

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

Discussion.

For the first part we compare the definition of injectivity with the assertion that two members of f−1({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 f−1({y})f^{-1}(\{y\}) is non-empty exactly when some x∈Ax \in A satisfies f(x)=yf(x) = y, which is what surjectivity asks.

Proof.

Suppose ff is injective. If x1,x2∈f−1({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 f−1({y})f^{-1}(\{y\}), and hence they are equal. This proves the first part.

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

Example 4.32 (Informal).

For a real number cc, the translation τc:R→R\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=y−cx = y - c; then τc(x)=(y−c)+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:R→Rq : 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×W→Wm : 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?

Problem 4.16.

A function f:A→Bf : A \to B is a set of ordered pairs, so its pairs may be reversed to form the set ρ(f)=def{(y,x)∈B×A∣(x,y)∈f}\rho(f) \defeq \{(y, x) \in B \times A \mid (x, y) \in f\}. Call the set of first coordinates of a set of pairs its domain.

  1. Determine ρ\rho of the set {(1,r),(2,s),(3,r)}\{(1, r), (2, s), (3, r)\} of Problem 4.8 and of the function ff of Problem 4.9 , and say which of the two is a function.
  2. Prove that if ff is not injective, then ρ(f)\rho(f) is not a function.
  3. Prove that if ff is injective but not surjective, then ρ(f)\rho(f) is a function whose domain DD satisfies D⊊BD \subsetneq B.

Bijections

Definition 4.35 (Bijection).

A function f:A→Bf : 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:A→Bf : A \to B is bijective if and only if for every y∈By \in B there is a unique x∈Ax \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 y∈By \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 y∈By \in B, an x∈Ax \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 y∈By \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 β:A→B\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:A→Bf : 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 x∈Ax \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 y∈f(A)y \in f(A) is f(x)f(x) for some x∈Ax \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 y∈Ay \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.17.

Let f:A→Bf : A \to B be bijective and let S⊂AS \subset A. Prove that the restriction f∣S:S→f(S)f|_S : S \to f(S) is bijective.

Problem 4.18.

For each of the following, exhibit sets AA and BB, a subset C⊂AC \subset A and a function f:A→Bf : A \to B meeting the condition, or show that none exists.

  1. ff is surjective and f∣Cf|_C is surjective.
  2. ff is surjective and f∣Cf|_C is not.
  3. ff is injective and f∣Cf|_C is injective.
  4. ff is injective and f∣Cf|_C is not.

Problem 4.19.

Let f:A→Bf : A \to B be injective and let S,T⊂AS, T \subset A. Prove that f(S∩T)=f(S)∩f(T)f(S \cap T) = f(S) \cap f(T).

Problem 4.20.

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:A→Bf : A \to B and g:B→Cg : B \to C be functions. Their composition is the function g∘f:A→Cg \circ f : A \to C given by (g∘f)(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 (τ1∘q)(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≠τ1∘qq \circ \tau_1 \neq \tau_1 \circ q by Proposition 4.19 . Composition is not commutative.

Theorem 4.41 (Associativity of composition).

Let f:A→Bf : A \to B, g:B→Cg : B \to C and h:C→Dh : C \to D be functions. Then h∘(g∘f)=(h∘g)∘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 x∈Ax \in A the definition of composition evaluates either side by applying ff, then gg, then hh.

Proof.

Both sides have domain AA. For every x∈Ax \in A, (h∘(g∘f))(x)=h(g(f(x)))=((h∘g)∘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 h∘g∘fh \circ g \circ f without brackets. The identity maps satisfy the identity laws one expects.

Proposition 4.42 (Identity laws).

If f:A→Bf : A \to B, then idB∘f=f\mathrm{id}_B \circ f = f and f∘idA=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 x∈Ax \in A the definitions of composition and of the identity map reduce both composites to f(x)f(x).

Proof.

For every x∈Ax \in A we have (idB∘f)(x)=idB(f(x))=f(x)(\mathrm{id}_B \circ f)(x) = \mathrm{id}_B(f(x)) = f(x) and (f∘idA)(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:A→Bf : A \to B and g:B→Cg : B \to C be functions.

  1. If ff and gg are injective, then g∘fg \circ f is injective;
  2. If ff and gg are surjective, then g∘fg \circ f is surjective;
  3. If ff and gg are bijective, then g∘fg \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 z∈Cz \in C, choose y∈By \in B with g(y)=zg(y) = z, then choose x∈Ax \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 (g∘f)(x1)=(g∘f)(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 z∈Cz \in C. Since gg is surjective, some y∈By \in B has g(y)=zg(y) = z; since ff is surjective, some x∈Ax \in A has f(x)=yf(x) = y. Then (g∘f)(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.21.

Let f:A→Bf : A \to B and g:B→Cg : B \to C. Prove that if g∘fg \circ f is injective then ff is injective, and that if g∘fg \circ f is surjective then gg is surjective.

Problem 4.22.

Construct finite sets AA, BB, CC and functions f:A→Bf : A \to B, g:B→Cg : B \to C for which g∘fg \circ f is bijective although ff is not surjective and gg is not injective.

Inverse Functions

Definition 4.44 (Inverse function).

Let f:A→Bf : A \to B and g:B→Ag : B \to A be functions. The function gg is an inverse of ff if g∘f=idAg \circ f = \mathrm{id}_A and f∘g=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 g∘f=idAg \circ f = \mathrm{id}_A; to get surjectivity, use g(y)g(y) as a preimage of an arbitrary y∈By \in B and use f∘g=idBf \circ g = \mathrm{id}_B. Conversely, Proposition 4.36 gives exactly one reversed pair (y,x)(y, x) for each y∈By \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:A→Bf : A \to B have an inverse g:B→Ag : 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 y∈By \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 y∈By \in B, Proposition 4.36 gives a unique x∈Ax \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 x∈Ax \in A and f(g(y))=yf(g(y)) = y for y∈By \in B, that is, g∘f=idAg \circ f = \mathrm{id}_A and f∘g=idBf \circ g = \mathrm{id}_B.

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

g=idA∘g=(h∘f)∘g=h∘(f∘g)=h∘idB=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 f−1f^{-1}. The construction in the proof gives

f−1={(y,x)∈B×A∣(x,y)∈f},sof−1(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 f−1f^{-1} also denotes the preimage of a set. The two uses are distinct: f−1(y)f^{-1}(y) is an element of AA produced by the inverse function, and exists only for a bijection, while f−1(U)f^{-1}(U) is a subset of AA and is defined for every function. For a bijection they are related by f−1({y})={f−1(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 idA−1=idA\mathrm{id}_A^{-1} = \mathrm{id}_A for any set AA.

Example 4.47 (Informal).

The translations invert one another: τc−1=τ−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:A→Bf : A \to B is bijective, then f−1:B→Af^{-1} : B \to A is bijective and (f−1)−1=f(f^{-1})^{-1} = f.

Discussion.

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

Proof.

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

Theorem 4.49 (Inverse of a composition).

If f:A→Bf : A \to B and g:B→Cg : B \to C are bijections, then (g∘f)−1=f−1∘g−1(g \circ f)^{-1} = f^{-1} \circ g^{-1}.

Discussion.

Put k=deff−1∘g−1k \defeq f^{-1} \circ g^{-1}. Rather than compute (g∘f)−1(g \circ f)^{-1} we show directly that kk meets the definition of an inverse of g∘fg \circ f: evaluate k∘(g∘f)k \circ (g \circ f) at an arbitrary x∈Ax \in A and (g∘f)∘k(g \circ f) \circ k at an arbitrary z∈Cz \in C, where associativity and the inverse identities cancel the adjacent pairs. Since g∘fg \circ f is bijective, uniqueness of inverses then identifies kk as the one.

Proof.

Put k=deff−1∘g−1:C→Ak \defeq f^{-1} \circ g^{-1} : C \to A. For x∈Ax \in A and z∈Cz \in C,

(k∘(g∘f))(x)=f−1(g−1(g(f(x))))=x,((g∘f)∘k)(z)=g(f(f−1(g−1(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 g∘fg \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:B→Cf : B \to C be bijective and let g,h:A→Bg, h : A \to B. Then f∘g=f∘hf \circ g = f \circ h implies g=hg = h. Likewise, if f:A→Bf : A \to B is bijective and r,s:B→Cr, s : B \to C, then r∘f=s∘fr \circ f = s \circ f implies r=sr = s.

Proof.

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

g=(f−1∘f)∘g=f−1∘(f∘g)=f−1∘(f∘h)=(f−1∘f)∘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 f−1f^{-1}:

r=r∘(f∘f−1)=(r∘f)∘f−1=(s∘f)∘f−1=s∘(f∘f−1)=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.23 (Informal).

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

Problem 4.24.

Let f:A→Bf : A \to B be bijective and let S⊂AS \subset A. Determine the inverse of f∣S:S→f(S)f|_S : S \to f(S).

Problem 4.25.

Let f:A→Bf : A \to B and g:B→Ag : B \to A. Prove that g∘f=idAg \circ f = \mathrm{id}_A forces ff to be injective and gg to be surjective, while f∘g=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:A→Bf : A \to B and g:B→Ag : B \to A be functions. The function gg is a left inverse of ff if g∘f=idAg \circ f = \mathrm{id}_A, and a right inverse of ff if f∘g=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 two implications: a left inverse makes ff injective, and a right inverse makes ff surjective. The next theorem combines them.

Theorem 4.52 (Bijections via one-sided inverses).

Let f:A→Bf : 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 f−1f^{-1}.

Discussion.

One direction is immediate: a bijection has f−1f^{-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 f−1f^{-1} exists. To identify the one-sided inverses with each other we evaluate the triple composite gl∘f∘grg_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 f−1f^{-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 y∈By \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 f−1f^{-1} exists by Theorem 4.45 . Associativity and the identity laws give

gl=gl∘idB=gl∘(f∘gr)=(gl∘f)∘gr=idA∘gr=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 f−1f^{-1} is itself both a left and a right inverse of ff, the same computation identifies their common value with f−1f^{-1}.

Conversely, if ff is bijective then f−1f^{-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:A→Bf : 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 B∖f(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 g∘f=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 x0∈Ax_0 \in A, which we may do since AA is non-empty, and define g:B→Ag : B \to A by g(y)=defh(y)g(y) \defeq h(y) for y∈f(A)y \in f(A) and g(y)=defx0g(y) \defeq x_0 for y∈B∖f(A)y \in B \setminus f(A). For every x∈Ax \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 g∘f=idAg \circ f = \mathrm{id}_A.

For surjections the situation is different. 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 y∈By \in B at once, one element of f−1({y})f^{-1}(\{y\}), and when BB is infinite nothing among our axioms says such a simultaneous choice can be made. That is what the axiom of choice provides.

Problem 4.26.

Let AA be non-empty and f:A→Bf : 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 φ:I→P(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 forgets the labels, as in the earlier example, 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{f∈P(I×⋃α∈IAα)  ∣  f is a function, dom⁡f=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 a∈Aa \in A and b∈Bb \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={f∈P(I×A)∣f is a function with dom⁡f=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\}.

Problem 4.27.

Let AA, BB and CC be sets, with BAB^A the Cartesian power of Definition 4.56 .

  1. Prove that if A⊂BA \subset B, then AC⊂BCA^C \subset B^C.
  2. Prove that ∅A=∅\emptyset^A = \emptyset for every non-empty AA, and that B∅={∅}B^{\emptyset} = \{\emptyset\} for every BB.
  3. Prove that AB∩AC=∅A^B \cap A^C = \emptyset whenever B≠CB \neq C, and deduce that {1,2}{1,2}\{1, 2\}^{\{1,2\}} and {1,2}{1,2,3}\{1, 2\}^{\{1,2,3\}} are disjoint.

Problem 4.28.

Let SS be a set. For each A⊂SA \subset S, the characteristic function of AA is the function χA:S→{0,1}\chi_A : S \to \{0, 1\} with χA(x)=def1\chi_A(x) \defeq 1 for x∈Ax \in A and χA(x)=def0\chi_A(x) \defeq 0 for x∉Ax \notin A; so χA(1)=χA(2)=χA(4)=1\chi_A(1) = \chi_A(2) = \chi_A(4) = 1 and χA(3)=0\chi_A(3) = 0 when S={1,2,3,4}S = \{1, 2, 3, 4\} and A={1,2,4}A = \{1, 2, 4\}.

  1. Give the formulas for χ∅\chi_{\emptyset} and χS\chi_S.
  2. Express χA‾\chi_{\overline{A}} in terms of χA\chi_A, where A‾\overline{A} is the complement of AA in SS.
  3. Prove that A=BA = B if and only if χA=χB\chi_A = \chi_B, for all A,B⊂SA, B \subset S.
  4. Prove that χA∩B(x)=χA(x) χB(x)\chi_{A \cap B}(x) = \chi_A(x)\,\chi_B(x) and χA∪B(x)=χA(x)+χB(x)−χA(x) χB(x)\chi_{A \cup B}(x) = \chi_A(x) + \chi_B(x) - \chi_A(x)\,\chi_B(x) for every x∈Sx \in S.

Problem 4.29.

Keep the characteristic functions of the previous problem.

  1. Prove that every function u:S→{0,1}u : S \to \{0, 1\} is χA\chi_A for exactly one A⊂SA \subset S.
  2. Suppose SS has nn elements. Determine the number of elements of {0,1}S\{0, 1\}^S, and use the first part to count P(S)\mathcal{P}(S).

Problem 4.30.

Let SS be a set.

  1. Prove that no function g:S→P(S)g : S \to \mathcal{P}(S) is surjective.
  2. Deduce that there is no bijection from SS to P(S)\mathcal{P}(S), and decide whether there can be a surjection from P(S)\mathcal{P}(S) to SS.

The product of two non-empty sets is non-empty, witnessed by any pair (x,y)(x, y) with x∈Ax \in A and y∈By \in B, and the same argument covers three sets, four, and any collection we can write out in full. Once II is infinite 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 dom⁡f=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 point is the order of the quantifiers: 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:A→Bf : A \to B be surjective. Then ff has a right inverse g:B→Ag : B \to A.

Discussion.

Surjectivity says, through Proposition 4.31 , that every point preimage f−1({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)∈f−1({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 needed here: 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 y∈By \in B the set f−1({y})f^{-1}(\{y\}) is non-empty by Proposition 4.31 . Applying the axiom of choice to the family {f−1({y})}y∈B\{f^{-1}(\{y\})\}_{y \in B} gives a function φ\varphi from BB to ⋃y∈Bf−1({y})\bigcup_{y \in B} f^{-1}(\{y\}) with φ(y)∈f−1({y})\varphi(y) \in f^{-1}(\{y\}) for every y∈By \in B. Each point preimage is a subset of AA, so that union is AA and φ:B→A\varphi : B \to A. Finally φ(y)∈f−1({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:A→Bf : 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 y∈By \in B, so g(y)g(y) is a preimage of yy and ff is surjective.

Problem 4.31.

Let I={1,2,3}I = \{1, 2, 3\} and let {Mi}i∈I\{M_i\}_{i \in I} be a family of non-empty sets. Show that ∏i∈IMi\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

(S∩T)×(S∪T)(S \cap T) \times (S \cup T) is:

answer one of these

Exercise 4.2.

Write aa and bb for the statements x∈Ax \in A and x∈Bx \in B, and cc and dd for y∈Cy \in C and y∈Dy \in D. Give the condition on the pair (x,y)(x, y) for membership in each set below.

(A∪B)×(C∪D)(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.

⋃i∈IAi‾\bigcup_{i \in I} \overline{A_i} is:

answer one of these

⋂i∈IAi‾\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}i∈I\{A_i\}_{i \in I} be a family with Ai⊂AjA_i \subset A_j whenever i⩽ji \leqslant j.

⋃i∈IAi\bigcup_{i \in I} A_i and ⋂i∈IAi\bigcap_{i \in I} A_i are:

answer one of these

Exercise 4.5.

A family {Ai}i∈I\{A_i\}_{i \in I} is disjoint if ⋂i∈IAi=∅\bigcap_{i \in I} A_i = \emptyset, and pairwise disjoint if Ai∩Aj=∅A_i \cap A_j = \emptyset whenever i≠ji \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 B∅B^{\emptyset} is:

answer one of these

Exercise 4.8.

Take the real numbers on trust and let q:R→Rq : 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

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

answer one of these

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

answer one of these

A function f:A→Bf : A \to B satisfies f−1(f(S))=Sf^{-1}(f(S)) = S for every S⊂AS \subset A exactly when it is:

answer one of these

And f(f−1(U))=Uf(f^{-1}(U)) = U holds for every U⊂BU \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 ι:S→T\iota : S \to T of a set SS with S⊊TS \subsetneq T is:

answer one of these

A constant map c:A→Bc : 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 R→RR \to R given by q(x)=defx2q(x) \defeq x^2, τ(x)=defx+1\tau(x) \defeq x + 1 and N(x)=def∣x∣N(x) \defeq |x|, where ∣x∣|x| is xx when x⩾0x \geqslant 0 and −x-x otherwise.

The function x↦∣x+1∣x \mapsto |x + 1| is:

answer one of these

The composites N∘qN \circ q and q∘Nq \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:A→Bf : A \to B and g:B→Cg : B \to C be bijections. The composite g−1∘f−1g^{-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.

One piece of the last chapter is written out here for the first time as well: a set listed by its members, {x} and {x, y}. Its membership criterion is the equation the pairing axiom gives, so y ∈ {x} is y = x, and the later exercises use it to name a set with a single point in it.

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}i∈I\{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 outside an intersection misses some set, but we are not given its index: 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 contradicts the hypothesis.

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, which is 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 follows from the criterion.

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 exactly when the map is injective.

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

Exercise 4.39.

And the other inclusion becomes an equality for a surjective one.

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

Exercise 4.40.

An image loses no more than the part removed.

lean proof
1example (f : Obj → Obj) (A S : Obj) : f '' A \ f '' S ⊆ f '' (A \ S) := by
goalf : Obj → Obj A S : Obj ⊢ f '' A \ f '' S ⊆ f '' (A \ S)

Exercise 4.41.

Injectivity closes the gap.

lean proof
1example (f : Obj → Obj) (A S : Obj) :2    Injective f → f '' (A \ S) = f '' A \ f '' S := by
goalf : Obj → Obj A S : Obj ⊢ Injective f → f '' (A \ S) = f '' A \ f '' S

Exercise 4.42.

The converse of the exercise three above: only an injection returns every set unchanged.

lean proof
1example (f : Obj → Obj) : (∀ S : Obj, f ⁻¹' (f '' S) = S) → Injective f := by
goalf : Obj → Obj ⊢ (∀ (S : Obj), f ⁻¹' (f '' S) = S) → Injective f

Exercise 4.43.

And nothing but a surjection.

lean proof
1example (f : Obj → Obj) : (∀ U : Obj, f '' (f ⁻¹' U) = U) → Surjective f := by
goalf : Obj → Obj ⊢ (∀ (U : Obj), f '' (f ⁻¹' U) = U) → Surjective f

A map f:A→Bf : A \to B carries two maps between the power sets with it, F:P(A)→P(B)F : \mathcal{P}(A) \to \mathcal{P}(B) sending SS to f(S)f(S) and G:P(B)→P(A)G : \mathcal{P}(B) \to \mathcal{P}(A) sending UU to f−1(U)f^{-1}(U). The checker has no power set to quantify over, so each of the four statements below says what injectivity or surjectivity of FF or of GG amounts to at the level of the sets themselves.

Exercise 4.44.

ff is injective exactly when FF is.

lean proof
1example (f : Obj → Obj) : Injective f ↔ ∀ S T : Obj, f '' S = f '' T → S = T := by
goalf : Obj → Obj ⊢ Injective f ↔ (∀ (S : Obj), ∀ (T : Obj), f '' S = f '' T → S = T)

Exercise 4.45.

And surjective exactly when FF is.

lean proof
1example (f : Obj → Obj) : Surjective f ↔ ∀ U : Obj, ∃ S : Obj, f '' S = U := by
goalf : Obj → Obj ⊢ Surjective f ↔ (∀ (U : Obj), ∃ S : Obj, f '' S = U)

Exercise 4.46.

The other pairing: ff is injective exactly when GG is surjective.

lean proof
1example (f : Obj → Obj) : Injective f ↔ ∀ S : Obj, ∃ U : Obj, f ⁻¹' U = S := by
goalf : Obj → Obj ⊢ Injective f ↔ (∀ (S : Obj), ∃ U : Obj, f ⁻¹' U = S)

Exercise 4.47.

And surjective exactly when GG is injective.

lean proof
1example (f : Obj → Obj) :2    Surjective f ↔ ∀ U V : Obj, f ⁻¹' U = f ⁻¹' V → U = V := by
goalf : Obj → Obj ⊢ Surjective f ↔ (∀ (U : Obj), ∀ (V : Obj), f ⁻¹' U = f ⁻¹' V → U = V)
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