Book 2A

© 2026 Neckpinch · www.neckpinch.com · All rights reserved.

Course 2Book 2A: Numbers, Limits and the IntegralChapter 2

Sets, Functions and Equivalence

The language of sets and maps, and quotients: treating different things as the same.

63 min read · Updated Oct 20, 2026

Read with Tao, Analysis I, chapter "Set theory" (fundamentals, Russell's paradox, functions, images and inverse images, Cartesian products). Its last section, on cardinality, is the subject of 2A.8 Infinite Sets.

In this chapter · 9 sections
  1. 2.1Sets
  2. 2.1.1Which sets exist
  3. 2.1.2Operations on sets
  4. 2.2Proving set identities
  5. 2.2.1The method: chase an element
  6. 2.2.2Disproving an identity
  7. 2.3Functions
  8. 2.3.1Injective, surjective, bijective
  9. 2.4Working with injections and surjections
  10. 2.5Images and preimages
  11. 2.6Cartesian products and relations
  12. 2.7Equivalence relations and quotients
  13. 2.7.1Functions on a quotient must be well defined
  14. 2.7.2Equivalence is a strong requirement
  15. 2.8Working with quotients
  16. 2.8.1Every function defines an equivalence relation
  17. 2.8.2Every function factors through a quotient
  18. 2.8.3Operations on a quotient
  19. 2.9Exercises
  20. ↗Free resources

The previous chapter built the natural numbers and nothing else. Before building any other numbers we need a language for collections of things and for rules that turn one thing into another: sets and functions. Almost every definition from here to Perelman is written in this language. A Riemannian metric is a function, a manifold is a set with extra structure, and the space of all metrics is a set of functions.

This chapter also introduces the idea that does the most work in the next two chapters, and keeps doing work until the end of the route: equivalence relations and quotients. They are the precise way of saying "treat these different things as the same". The integers, the rationals and the real numbers are all built as quotients. So is the circle, the lens spaces of topology, and, at the very end, the space in which Ricci flow really lives: metrics up to a change of coordinates.

By the end of this chapter you will be able to:

  • work with sets, subsets and the operations on them, and prove or disprove set identities by chasing elements;
  • say exactly what a function is, and when two functions are equal;
  • decide whether a function is injective, surjective or bijective, and invert a bijection;
  • compute images and preimages, and explain why preimages behave better;
  • define an equivalence relation, describe its classes, form the quotient set, and check that a function on a quotient is well defined;
  • factor any function through a quotient, and define arithmetic on a quotient such as clock arithmetic.

Sets

A set is a collection of objects, called its elements. We write x∈Ax \in A when xx is an element of AA, and x∉Ax \notin A when it isn't. A set is completely determined by its elements: two sets are equal exactly when they have the same elements. So {1,2,3}\{1, 2, 3\}, {3,2,1}\{3, 2, 1\} and {1,1,2,3}\{1, 1, 2, 3\} are the same set. Order and repetition don't matter, only membership.

Definition 2.1 Subsets

A set AA is a subset of a set BB, written A⊆BA \subseteq B, if every element of AA is also an element of BB. It is a proper subset, written A⊊BA \subsetneq B, if in addition A≠BA \neq B.

Equality of sets is then the same as inclusion both ways: A=BA = B if and only if A⊆BA \subseteq B and B⊆AB \subseteq A. This is how almost every set identity is proved. To show two sets are equal, take an arbitrary element of one, show it lies in the other, and then do the same in the other direction.

Which sets exist

To build sets we need some agreed ways of making them. Tao lists them as axioms, and the ones we use constantly are these.1 These are, in slightly informal form, the axioms of Zermelo–Fraenkel set theory, the standard foundation of modern mathematics. You don't need to memorise them; you need to know that every set used in this guidebook is built by them.

  • There is an empty set ∅\varnothing with no elements.
  • For any objects aa and bb there are the sets {a}\{a\} and {a,b}\{a, b\}.
  • For any sets AA and BB there is the union A∪BA \cup B, whose elements are those that lie in AA or in BB (or both).
  • Specification. For any set AA and any property P(x)P(x), there is a set {x∈A:P(x)}\{x \in A : P(x)\} of the elements of AA that have the property.
  • Replacement. For any set AA and any rule assigning an object f(x)f(x) to each x∈Ax \in A, there is a set {f(x):x∈A}\{f(x) : x \in A\}.
  • Infinity. The natural numbers N\mathbb{N} form a set.
  • Power set. For any set AA there is the set of all its subsets.

The specification axiom deserves attention because of what it does not allow. It lets you carve a subset out of a set you already have. It does not let you form "the set of all xx with property PP" with no ambient set, and the reason is one of the most famous arguments in mathematics.

History Russell's paradox

Suppose any property defined a set. Consider the property "xx is a set that is not an element of itself", and let RR be the set of all such xx. Is RR an element of itself? If R∈RR \in R, then RR has the defining property, so R∉RR \notin R. If R∉RR \notin R, then RR has the property, so R∈RR \in R. Either way, a contradiction.

Bertrand Russell found this in 1901 and wrote to Gottlob Frege in 1902, just as the second volume of Frege's Grundgesetze der Arithmetik was going to press. Frege's system, an attempt to found arithmetic on logic, allowed exactly this kind of unrestricted set formation, and the paradox showed it was inconsistent. He added an appendix acknowledging the problem. The modern response is the axioms above, which only ever build sets out of sets already in hand.

Operations on sets

Definition 2.2 Union, intersection, difference

Let AA and BB be sets.

  • The intersection A∩B={x∈A:x∈B}A \cap B = \{x \in A : x \in B\} consists of the elements in both.
  • The difference A∖B={x∈A:x∉B}A \setminus B = \{x \in A : x \notin B\} consists of the elements of AA not in BB.
  • AA and BB are disjoint if A∩B=∅A \cap B = \varnothing.

When all the sets in a discussion are subsets of one fixed set XX, the difference X∖AX \setminus A is called the complement of AA (in XX), written AcA^c.

Often we need the union or intersection of many sets at once, perhaps infinitely many: the intervals [0,1−1n][0, 1 - \tfrac1n] for n=1,2,3,…n = 1, 2, 3, \dots, say. A family of sets indexed by a set II is an assignment of a set AαA_\alpha to each index α∈I\alpha \in I.

Definition 2.3 Unions and intersections of a family

Let (Aα)α∈I(A_\alpha)_{\alpha \in I} be a family of sets.

  • The union ⋃α∈IAα\bigcup_{\alpha \in I} A_\alpha is the set of xx that lie in AαA_\alpha for at least one α\alpha.
  • If II is nonempty, the intersection ⋂α∈IAα\bigcap_{\alpha \in I} A_\alpha is the set of xx that lie in AαA_\alpha for every α\alpha.

So "union" is "there exists an index" and "intersection" is "for every index". For example, ⋃n≥1[0,1−1n]=[0,1)\bigcup_{n \geq 1} [0, 1 - \tfrac1n] = [0, 1): every xx with 0≤x<10 \leq x < 1 lies in some interval (take nn with 1n≤1−x\tfrac1n \leq 1 - x), but 11 lies in none of them. And ⋂n≥1(−1n,1n)={0}\bigcap_{n \geq 1} (-\tfrac1n, \tfrac1n) = \{0\}: 00 is in every interval, and any x≠0x \neq 0 falls outside the interval with 1n<∣x∣\tfrac1n < |x|. (These two computations use the Archimedean property of the reals from 2A.4 The Real Numbers; for now take them on trust.) Notice that an infinite union of closed intervals need not be closed, and an infinite intersection of open intervals need not be open. That is the first sign of a theme in 2B.1 Metric Spaces.2 The intersection of an empty family is left undefined: "every xx that lies in every AαA_\alpha" would then be every object whatsoever, which is not a set. Inside a fixed XX one sometimes sets it equal to XX by convention.

The power set of AA, written 2A2^A or P(A)\mathcal{P}(A), is the set of all subsets of AA. For A={1,2}A = \{1, 2\} it is {∅,{1},{2},{1,2}}\{\varnothing, \{1\}, \{2\}, \{1, 2\}\}, with four elements. Its elements are sets, so a power set is a set of sets; that is normal, and families of subsets of a fixed set are exactly what topology and measure theory are built from (2B.1 Metric Spaces, 3A.2 Lebesgue Measure).

Figure 2.1. The four basic operations. Venn diagrams are good for intuition, but they are not proofs: a proof works with elements.

These operations obey a long list of laws: union and intersection are commutative and associative, each distributes over the other, and so on. They are all proved the same way, element by element. Here is the most useful pair in full.

Proposition 2.4 De Morgan's laws

Let AA and BB be subsets of a set XX. Then

(A∪B)c=Ac∩Bcand(A∩B)c=Ac∪Bc.(A \cup B)^c = A^c \cap B^c \qquad\text{and}\qquad (A \cap B)^c = A^c \cup B^c.

More generally, for any family of subsets AαA_\alpha of XX, indexed by α\alpha in some set II,

(⋃α∈IAα)c=⋂α∈IAαcand(⋂α∈IAα)c=⋃α∈IAαc.\Big(\bigcup_{\alpha \in I} A_\alpha\Big)^c = \bigcap_{\alpha \in I} A_\alpha^c \qquad\text{and}\qquad \Big(\bigcap_{\alpha \in I} A_\alpha\Big)^c = \bigcup_{\alpha \in I} A_\alpha^c.

Proof. We prove the first law for a family; the others are the same argument. Let x∈Xx \in X. Then xx lies in the left-hand side exactly when xx is not in ⋃αAα\bigcup_\alpha A_\alpha, that is, when there is no α\alpha with x∈Aαx \in A_\alpha. That says x∉Aαx \notin A_\alpha for every α\alpha, which means x∈Aαcx \in A_\alpha^c for every α\alpha, which is membership of the right-hand side. Each step is an "if and only if", so the two sets have the same elements.

Notice the logic inside the proof: "not (there exists α\alpha with …)" became "for every α\alpha, not …". De Morgan's laws for sets are the rules for negating "there exists" and "for all". Chapter 2A.5 Quantifiers and the Shape of a Proof makes that rule a central skill.

Proving set identities

If you have only ever seen set identities illustrated with Venn diagrams, proving them can feel strange at first: what is there to prove? This section is about the method, which is completely mechanical once you see it, and which you will use for every set identity from here on.

The method: chase an element

To prove A=BA = B for two sets built from others:

  1. Let xx be an arbitrary element of AA.
  2. Unfold the definitions: write out what "x∈Ax \in A" means in words, using "and", "or", "not".
  3. Reason with those words until you reach what "x∈Bx \in B" means. This proves A⊆BA \subseteq B.
  4. Do the same starting from x∈Bx \in B, or, if every step in 3 was an "if and only if", note that the argument runs backwards too. This proves B⊆AB \subseteq A.

The translation table is short. x∈A∩Bx \in A \cap B means "x∈Ax \in A and x∈Bx \in B". x∈A∪Bx \in A \cup B means "x∈Ax \in A or x∈Bx \in B" (inclusive or). x∈A∖Bx \in A \setminus B means "x∈Ax \in A and not x∈Bx \in B". And x∈Acx \in A^c means "not x∈Ax \in A" (with x∈Xx \in X understood).

Proposition 2.5 The algebra of sets

For subsets AA, BB, CC of a set XX:

  1. A∪B=B∪AA \cup B = B \cup A and A∩B=B∩AA \cap B = B \cap A;
  2. (A∪B)∪C=A∪(B∪C)(A \cup B) \cup C = A \cup (B \cup C) and (A∩B)∩C=A∩(B∩C)(A \cap B) \cap C = A \cap (B \cap C);
  3. A∩(B∪C)=(A∩B)∪(A∩C)A \cap (B \cup C) = (A \cap B) \cup (A \cap C) and A∪(B∩C)=(A∪B)∩(A∪C)A \cup (B \cap C) = (A \cup B) \cap (A \cup C);
  4. A∪∅=AA \cup \varnothing = A, A∩X=AA \cap X = A, A∪Ac=XA \cup A^c = X, A∩Ac=∅A \cap A^c = \varnothing, (Ac)c=A(A^c)^c = A;
  5. A∖B=A∩BcA \setminus B = A \cap B^c.

Proof (Two of the laws, as models). The second distributive law. Let x∈A∪(B∩C)x \in A \cup (B \cap C). Then x∈Ax \in A, or xx is in both BB and CC. If x∈Ax \in A, then x∈A∪Bx \in A \cup B and x∈A∪Cx \in A \cup C. If x∈Bx \in B and x∈Cx \in C, then again x∈A∪Bx \in A \cup B and x∈A∪Cx \in A \cup C. Either way x∈(A∪B)∩(A∪C)x \in (A \cup B) \cap (A \cup C).

Conversely, let x∈(A∪B)∩(A∪C)x \in (A \cup B) \cap (A \cup C), so x∈A∪Bx \in A \cup B and x∈A∪Cx \in A \cup C. If x∈Ax \in A, then x∈A∪(B∩C)x \in A \cup (B \cap C). If x∉Ax \notin A, then x∈A∪Bx \in A \cup B forces x∈Bx \in B, and x∈A∪Cx \in A \cup C forces x∈Cx \in C; so x∈B∩Cx \in B \cap C. Either way x∈A∪(B∩C)x \in A \cup (B \cap C).

Part 5. x∈A∖Bx \in A \setminus B means x∈Ax \in A and x∉Bx \notin B, which means x∈Ax \in A and x∈Bcx \in B^c, which is x∈A∩Bcx \in A \cap B^c. Every step is an "if and only if", so the sets are equal.

The other laws are proved the same way. Part 4's (Ac)c=A(A^c)^c = A is the logical law "not not PP" is PP.

Notice the "If x∉Ax \notin A" move in the converse half. When you know "PP or QQ" and want to use it, split into cases: either PP holds, or PP fails and then QQ must hold. Case splits are the commonest step in element-chasing.

Example 2.6 A subset characterised by an equation

Claim: A⊆BA \subseteq B if and only if A∩B=AA \cap B = A.

Suppose A⊆BA \subseteq B. We show A∩B=AA \cap B = A. Always A∩B⊆AA \cap B \subseteq A: an element of both is an element of AA. Conversely, if x∈Ax \in A then x∈Bx \in B (because A⊆BA \subseteq B), so x∈A∩Bx \in A \cap B.

Suppose A∩B=AA \cap B = A. If x∈Ax \in A, then x∈A∩Bx \in A \cap B, so x∈Bx \in B. Hence A⊆BA \subseteq B.

An "if and only if" claim needs two proofs, one for each direction, and it is good practice to label them as above.

Disproving an identity

To show that a proposed identity is false, you need one counterexample: specific sets for which the two sides differ. Small finite sets are best, because you can compute everything.

Example 2.7 Difference is not undone by union

Is (A∖B)∪B=A(A \setminus B) \cup B = A for all sets AA and BB? Try A={1}A = \{1\} and B={2}B = \{2\}. Then A∖B={1}A \setminus B = \{1\} and (A∖B)∪B={1,2}≠A(A \setminus B) \cup B = \{1, 2\} \neq A. So the identity is false.

What is true? Element-chasing gives (A∖B)∪B=A∪B(A \setminus B) \cup B = A \cup B: an element of the left side is in AA or in BB; and an element of A∪BA \cup B is either in BB, or in AA but not in BB. So the identity holds exactly when A∪B=AA \cup B = A, that is, when B⊆AB \subseteq A (by the dual of Example 2.6). Finding the correct version of a false statement is often more useful than the counterexample itself.

Careful Venn diagrams with two or three sets can mislead

A Venn diagram of two or three circles shows every combination of "in" and "out", so it really can check identities involving two or three sets. With four or more sets, circles can't show all combinations, and a picture can make a false identity look true. Use pictures to guess, and element-chasing to prove.

Functions

Informally, a function from XX to YY is a rule that takes each element of XX and returns an element of YY. The precise definition makes three things part of the data: where inputs come from, where outputs land, and the rule.

Definition 2.8 Function

Let XX and YY be sets. A function f:X→Yf : X \to Y assigns to every x∈Xx \in X exactly one element f(x)∈Yf(x) \in Y. The set XX is the domain of ff, and YY is its codomain. Two functions f,g:X→Yf, g : X \to Y are equal if f(x)=g(x)f(x) = g(x) for every x∈Xx \in X.

Three consequences of the definition catch people out.

  • Every input gets an output. "f(x)=1/xf(x) = 1/x from R\mathbb{R} to R\mathbb{R}" is not a function, because 00 gets nothing. It becomes one if the domain is R∖{0}\mathbb{R} \setminus \{0\}.
  • Exactly one output. "f(y)f(y) is the number whose square is yy" is not a function on the positive reals, because 44 has two square roots. Choosing one ("the positive square root") makes it a function.
  • Equality is about values, not formulas. f(x)=x2−1f(x) = x^2 - 1 and g(x)=(x−1)(x+1)g(x) = (x - 1)(x + 1) are the same function. On the other hand, x↦x2x \mapsto x^2 as a function R→R\mathbb{R} \to \mathbb{R} and as a function R→[0,∞)\mathbb{R} \to [0, \infty) are, strictly speaking, different functions, because their codomains differ. That distinction matters for surjectivity, below.

One way to make "a rule" precise, using only sets, is through the function's graph, the set of pairs {(x,f(x)):x∈X}\{(x, f(x)) : x \in X\}. A function is its graph: a set of pairs in which every x∈Xx \in X appears as a first entry exactly once. Pairs need one more construction, the Cartesian product, which comes later in this chapter.

Composition. If f:X→Yf : X \to Y and g:Y→Zg : Y \to Z, the composition g∘f:X→Zg \circ f : X \to Z is x↦g(f(x))x \mapsto g(f(x)). Composition is associative, h∘(g∘f)=(h∘g)∘fh \circ (g \circ f) = (h \circ g) \circ f, because both send xx to h(g(f(x)))h(g(f(x))). It is not commutative: putting on socks and then shoes is not the same as shoes then socks.

Injective, surjective, bijective

Definition 2.9 Injective, surjective, bijective

A function f:X→Yf : X \to Y is

  • injective (one-to-one) if different inputs give different outputs: x≠x′x \neq x' implies f(x)≠f(x′)f(x) \neq f(x');
  • surjective (onto) if every element of YY is an output: for every y∈Yy \in Y there is some x∈Xx \in X with f(x)=yf(x) = y;
  • bijective if it is both.

You met injectivity already: 2A.1 The Natural Numbers's Axiom 1.4 says exactly that the successor map n↦n++n \mapsto n{+}{+} is injective. Together with Axiom 1.3 (00 is not a successor), it says that the successor map from N\mathbb{N} to N\mathbb{N} is injective but not surjective.

Figure 2.2. The four possibilities. Injective: no two arrows land on the same point. Surjective: every point of YY is hit. Bijective: both, so the arrows pair XX and YY off exactly.
Proposition 2.10 Inverses

A function f:X→Yf : X \to Y is bijective if and only if there is a function g:Y→Xg : Y \to X with g(f(x))=xg(f(x)) = x for every x∈Xx \in X and f(g(y))=yf(g(y)) = y for every y∈Yy \in Y. Such a gg is unique; it is the inverse of ff, written f−1f^{-1}.

Proof. If ff is bijective, then for each y∈Yy \in Y there is some xx with f(x)=yf(x) = y (surjectivity), and only one (injectivity). Define g(y)g(y) to be that xx. Then f(g(y))=yf(g(y)) = y by construction, and g(f(x))=xg(f(x)) = x because xx is the unique input sent to f(x)f(x).

Conversely, suppose such a gg exists. If f(x)=f(x′)f(x) = f(x'), apply gg: x=g(f(x))=g(f(x′))=x′x = g(f(x)) = g(f(x')) = x', so ff is injective. Given y∈Yy \in Y, the element x=g(y)x = g(y) satisfies f(x)=yf(x) = y, so ff is surjective.

For uniqueness, if gg and hh both work, then for every yy, g(y)=g(f(h(y)))=h(y)g(y) = g(f(h(y))) = h(y), using f(h(y))=yf(h(y)) = y and then g(f(x))=xg(f(x)) = x with x=h(y)x = h(y).

In the world In use Hashing: a function that can't be injective

A hash function turns any file, of any length, into a short fixed-length string. SHA-256, for example, outputs 256 bits, and it is used to check downloads, sign software and chain blocks together in cryptocurrencies. There are infinitely many possible inputs and only 22562^{256} possible outputs, so SHA-256 cannot be injective: some pair of different files must have the same hash (a collision). This is the pigeonhole principle: a function from a larger set into a smaller one can't be injective.

The security of a hash function rests not on injectivity, which is impossible, but on collisions being infeasible to find. When that fails, the function is retired. In 2017 a team from CWI Amsterdam and Google published the first practical collision for the older SHA-1, two different PDF files with the same SHA-1 hash, and SHA-1 has since been phased out of security-critical uses.

In the world In use Ciphers are bijections

An encryption scheme must be decryptable, so encryption with a fixed key must be injective. The simplest example is the Caesar shift on the alphabet, x↦x+3x \mapsto x + 3 with letters numbered 00 to 2525 and wrapping round after 2525 (exactly the clock arithmetic of 2A.1 The Natural Numbers). Its inverse is x↦x−3x \mapsto x - 3. Modern block ciphers such as AES are, for each key, bijections on the set of 128-bit blocks. Decryption is the inverse function.

Working with injections and surjections

Deciding whether a given function is injective or surjective is a skill you will use constantly, and, like induction, it has a standard shape.

  • To prove ff injective: take x,x′x, x' with f(x)=f(x′)f(x) = f(x') and deduce x=x′x = x'. (This is the contrapositive of the definition, and is almost always easier to use.)
  • To prove ff not injective: find two specific different inputs with the same output.
  • To prove ff surjective: take an arbitrary yy in the codomain and find an xx with f(x)=yf(x) = y. Usually you solve f(x)=yf(x) = y for xx in scratch work, and then check in the proof that your xx lies in the domain and really works.
  • To prove ff not surjective: find one specific yy in the codomain that no input reaches, and prove that none does.
Example 2.11 A bijection, and its inverse

Let f:R→Rf : \mathbb{R} \to \mathbb{R}, f(x)=3x+2f(x) = 3x + 2.

Injective. Suppose 3x+2=3x′+23x + 2 = 3x' + 2. Subtract 22 and divide by 33: x=x′x = x'.

Surjective. Given y∈Ry \in \mathbb{R}, scratch work: 3x+2=y3x + 2 = y means x=(y−2)/3x = (y - 2)/3. Now the proof: let x=(y−2)/3x = (y - 2)/3, which is a real number, and compute f(x)=3⋅y−23+2=yf(x) = 3 \cdot \frac{y - 2}{3} + 2 = y.

So ff is a bijection, and the scratch work found its inverse: f−1(y)=(y−2)/3f^{-1}(y) = (y - 2)/3. Check against Proposition 2.10: f−1(f(x))=(3x+2−2)/3=xf^{-1}(f(x)) = (3x + 2 - 2)/3 = x and f(f−1(y))=yf(f^{-1}(y)) = y.

Now consider the same formula as a map Z→Z\mathbb{Z} \to \mathbb{Z}. It is still injective (the same proof works), but no longer surjective: y=0y = 0 would need x=−23x = -\tfrac23, which is not an integer. Changing the domain and codomain changes the answer, which is why they are part of the function.

Example 2.12 The squaring map on four domains

Let s(x)=x2s(x) = x^2.

  • As a map R→R\mathbb{R} \to \mathbb{R}: not injective, since s(−1)=s(1)s(-1) = s(1); not surjective, since s(x)≥0s(x) \geq 0 for every xx, so −1-1 is never reached.
  • As a map R→[0,∞)\mathbb{R} \to [0, \infty): surjective (every y≥0y \geq 0 has a square root, y\sqrt y), not injective.
  • As a map [0,∞)→[0,∞)[0, \infty) \to [0, \infty): bijective. Injective: if x2=x′2x^2 = x'^2 with x,x′≥0x, x' \geq 0, then (x−x′)(x+x′)=0(x - x')(x + x') = 0, so x=x′x = x' or x+x′=0x + x' = 0, and the second forces x=x′=0x = x' = 0. Surjective: as before. The inverse is x\sqrt{\phantom{x}}.
  • As a map Q≥0→Q≥0\mathbb{Q}_{\geq 0} \to \mathbb{Q}_{\geq 0} on the non-negative rationals: injective (same proof), but not surjective, because 22 is not the square of any rational (2A.3 Integers and Rationals).

The step "every y≥0y \geq 0 has a square root" is a genuine theorem about the real numbers, not a triviality. It is proved in 2A.4 The Real Numbers, and it fails for the rationals. Much of real analysis consists of proving that some equation has a solution, that is, that some map is surjective.

Proposition 2.13 Composing bijections

If f:X→Yf : X \to Y and g:Y→Zg : Y \to Z are bijections, then g∘fg \circ f is a bijection, and (g∘f)−1=f−1∘g−1(g \circ f)^{-1} = f^{-1} \circ g^{-1}.

Proof. Let h=f−1∘g−1h = f^{-1} \circ g^{-1}. Then h(g(f(x)))=f−1(g−1(g(f(x))))=f−1(f(x))=xh(g(f(x))) = f^{-1}(g^{-1}(g(f(x)))) = f^{-1}(f(x)) = x, and similarly g(f(h(z)))=zg(f(h(z))) = z. So hh is an inverse for g∘fg \circ f, which is therefore a bijection by Proposition 2.10, and hh is its inverse by the uniqueness part of Proposition 2.10.

The order reverses, as with socks and shoes: to undo "socks, then shoes", take off the shoes first.

Injectivity and surjectivity each correspond to half of an inverse.

Proposition 2.14 One-sided inverses

Let f:X→Yf : X \to Y, with XX nonempty.

  1. ff is injective if and only if there is g:Y→Xg : Y \to X with g∘f=idXg \circ f = \mathrm{id}_X (a left inverse).
  2. ff is surjective if and only if there is h:Y→Xh : Y \to X with f∘h=idYf \circ h = \mathrm{id}_Y (a right inverse).

Here idX\mathrm{id}_X is the identity map x↦xx \mapsto x on XX.

Proof. (1) If g∘f=idXg \circ f = \mathrm{id}_X and f(x)=f(x′)f(x) = f(x'), then x=g(f(x))=g(f(x′))=x′x = g(f(x)) = g(f(x')) = x'. Conversely, suppose ff injective, and fix some x0∈Xx_0 \in X. For y∈f(X)y \in f(X), let g(y)g(y) be the unique xx with f(x)=yf(x) = y; for y∉f(X)y \notin f(X), let g(y)=x0g(y) = x_0. Then g(f(x))=xg(f(x)) = x for every xx.

(2) If f∘h=idYf \circ h = \mathrm{id}_Y, then each yy equals f(h(y))f(h(y)), so ff is surjective. Conversely, if ff is surjective, each yy has at least one xx with f(x)=yf(x) = y; let h(y)h(y) be one of them. Then f(h(y))=yf(h(y)) = y.

The last sentence of the proof hides something. "Let h(y)h(y) be one of them" makes a choice for every y∈Yy \in Y at once, and when YY is infinite and there is no rule to pick out a particular preimage, that is not something the axioms listed so far allow. It needs the axiom of choice, discussed in 2A.8 Infinite Sets. When there is a rule (as for x↦x2x \mapsto x^2 on [0,∞)[0, \infty), where we can choose "the non-negative root"), no extra axiom is needed.

Images and preimages

A function moves sets as well as points. There are two directions, and they behave very differently.

Definition 2.15 Image and preimage

Let f:X→Yf : X \to Y.

  • For S⊆XS \subseteq X, the image of SS is f(S)={f(x):x∈S}f(S) = \{f(x) : x \in S\}, the set of outputs of inputs from SS.
  • For U⊆YU \subseteq Y, the preimage (or inverse image) of UU is f−1(U)={x∈X:f(x)∈U}f^{-1}(U) = \{x \in X : f(x) \in U\}, the set of inputs whose outputs land in UU.

The notation f−1(U)f^{-1}(U) does not require ff to have an inverse. It makes sense for every function. If f(x)=x2f(x) = x^2 on R\mathbb{R}, then f−1({4})={−2,2}f^{-1}(\{4\}) = \{-2, 2\}, f−1({−1})=∅f^{-1}(\{-1\}) = \varnothing, and f−1([1,4])=[−2,−1]∪[1,2]f^{-1}([1, 4]) = [-2, -1] \cup [1, 2].

Preimages respect every set operation. Images don't.

Theorem 2.16 Preimages commute with set operations

Let f:X→Yf : X \to Y, and let U,VU, V and UαU_\alpha (for α∈I\alpha \in I) be subsets of YY. Then

f−1(⋃αUα)=⋃αf−1(Uα),f−1(⋂αUα)=⋂αf−1(Uα),f−1(Y∖U)=X∖f−1(U).f^{-1}\Big(\bigcup_\alpha U_\alpha\Big) = \bigcup_\alpha f^{-1}(U_\alpha), \qquad f^{-1}\Big(\bigcap_\alpha U_\alpha\Big) = \bigcap_\alpha f^{-1}(U_\alpha), \qquad f^{-1}(Y \setminus U) = X \setminus f^{-1}(U).

Proof. For the union: x∈f−1(⋃αUα)x \in f^{-1}(\bigcup_\alpha U_\alpha) means f(x)∈Uαf(x) \in U_\alpha for some α\alpha, which means x∈f−1(Uα)x \in f^{-1}(U_\alpha) for some α\alpha, which is membership of the right-hand side. The intersection is the same with "some" replaced by "every". For the complement: x∈f−1(Y∖U)x \in f^{-1}(Y \setminus U) means f(x)∉Uf(x) \notin U, which means x∉f−1(U)x \notin f^{-1}(U).

For images, only the union rule survives: f(S∪T)=f(S)∪f(T)f(S \cup T) = f(S) \cup f(T) always, but in general f(S∩T)⊊f(S)∩f(T)f(S \cap T) \subsetneq f(S) \cap f(T) can happen.

Proposition 2.17 What images do respect

Let f:X→Yf : X \to Y and S,T⊆XS, T \subseteq X. Then f(S∪T)=f(S)∪f(T)f(S \cup T) = f(S) \cup f(T) and f(S∩T)⊆f(S)∩f(T)f(S \cap T) \subseteq f(S) \cap f(T). If S⊆TS \subseteq T then f(S)⊆f(T)f(S) \subseteq f(T).

Proof. y∈f(S∪T)y \in f(S \cup T) means y=f(x)y = f(x) for some xx in SS or in TT; that is, y=f(x)y = f(x) for some x∈Sx \in S, or y=f(x)y = f(x) for some x∈Tx \in T; that is, y∈f(S)∪f(T)y \in f(S) \cup f(T). For the intersection: if y=f(x)y = f(x) with x∈S∩Tx \in S \cap T, then x∈Sx \in S gives y∈f(S)y \in f(S) and x∈Tx \in T gives y∈f(T)y \in f(T). The last claim is immediate from the definition.

The proof of the intersection rule only goes one way, and the example below shows why it can't go the other way. When you try to reverse it, you know y=f(s)y = f(s) with s∈Ss \in S and y=f(t)y = f(t) with t∈Tt \in T, but nothing says s=ts = t.

Example 2.18 Images lose information

Let f(x)=x2f(x) = x^2 on R\mathbb{R}, S=[−2,−1]S = [-2, -1] and T=[1,2]T = [1, 2]. Then S∩T=∅S \cap T = \varnothing, so f(S∩T)=∅f(S \cap T) = \varnothing. But f(S)=f(T)=[1,4]f(S) = f(T) = [1, 4], so f(S)∩f(T)=[1,4]f(S) \cap f(T) = [1, 4]. Points from SS and points from TT are sent to the same place, so after applying ff you can no longer tell them apart. If ff is injective this can't happen, and then f(S∩T)=f(S)∩f(T)f(S \cap T) = f(S) \cap f(T) (Exercise 2.35).

Figure 2.3. For f(x)=x2f(x) = x^2, the disjoint sets [−2,−1][-2,-1] and [1,2][1,2] have the same image [1,4][1,4], so the image of their intersection (∅\varnothing) is smaller than the intersection of their images. Read the figure backwards and you see the preimage: f−1([1,4])=[−2,−1]∪[1,2]f^{-1}([1,4]) = [-2,-1] \cup [1,2].
Where this goes Why the guidebook keeps using preimages

Theorem 2.16 looks like a technicality, but it decides how two of the central definitions in analysis are written. A function is continuous when the preimage of every open set is open (7A.1 Topological Spaces and Quotients), and measurable when the preimage of every measurable set is measurable (3A.3 The Lebesgue Integral). Both definitions use preimages because preimages respect unions, intersections and complements, which are the operations that define "open set" and "measurable set" in the first place. Images would not work.

In the world In use Thresholding an image is a preimage

A greyscale photograph is a function bb from the set of pixels to brightness values {0,1,…,255}\{0, 1, \dots, 255\}. "Select every pixel brighter than 200200", the first step in many image-segmentation tools and in counting stars, cells or defects in a picture, is the preimage b−1({201,…,255})b^{-1}(\{201, \dots, 255\}). Theorem 2.16 is why combining selections is easy: "bright or red" is the union of two preimages, "bright and red" is the intersection, and "not bright" is the complement.

Cartesian products and relations

Definition 2.19 Cartesian product

An ordered pair (x,y)(x, y) consists of a first entry xx and a second entry yy; two pairs are equal exactly when their first entries are equal and their second entries are equal. The Cartesian product of sets XX and YY is the set of all ordered pairs X×Y={(x,y):x∈X,y∈Y}X \times Y = \{(x, y) : x \in X, y \in Y\}. Products of more sets, X1×⋯×XnX_1 \times \dots \times X_n, consist of ordered nn-tuples.

So R2=R×R\mathbb{R}^2 = \mathbb{R} \times \mathbb{R} is the plane, and a function f:X→Yf : X \to Y can be identified with its graph, a subset of X×YX \times Y. If XX has mm elements and YY has nn, then X×YX \times Y has m×nm \times n, which is where the word "product" comes from.

Definition 2.20 Relation

A relation on a set XX is a subset R⊆X×XR \subseteq X \times X. We write x∼yx \sim y for (x,y)∈R(x, y) \in R.

"Less than" on N\mathbb{N} is a relation: the set of pairs (m,n)(m, n) with m<nm < n. So is "has the same birthday as" on the set of people.

In the world In use Relational databases store relations

Most of the world's business data sits in relational databases, a design proposed by Edgar F. Codd in 1970. A database table is literally a relation in the sense of Definition 2.19, generalised to more columns: a set of tuples. A CROSS JOIN of two tables is their Cartesian product, and an ordinary join is a subset of that product picked out by a condition, which is the specification axiom in action. Codd built his model directly on this set-theoretic language, which is why queries can be reasoned about mathematically and optimised automatically.

Equivalence relations and quotients

Some relations behave like equality. "Has the same remainder after division by 1212" is one: it treats 33, 1515 and 2727 as the same as far as a clock is concerned. Three properties capture what "behaves like equality" means.

Definition 2.21 Equivalence relation

A relation ∼\sim on a set XX is an equivalence relation if it is

  • reflexive: x∼xx \sim x for every xx;
  • symmetric: if x∼yx \sim y then y∼xy \sim x;
  • transitive: if x∼yx \sim y and y∼zy \sim z then x∼zx \sim z.

The equivalence class of xx is [x]={y∈X:y∼x}[x] = \{y \in X : y \sim x\}, everything equivalent to xx.

Example 2.22 Congruence modulo nn

Fix a positive natural number nn. For integers aa and bb, say a≡b(modn)a \equiv b \pmod n if a−ba - b is a multiple of nn. (We use the integers informally here; they are built properly in 2A.3 Integers and Rationals.) This is an equivalence relation: a−a=0=0⋅na - a = 0 = 0 \cdot n; if a−b=kna - b = kn then b−a=(−k)nb - a = (-k)n; and if a−b=kna - b = kn and b−c=lnb - c = ln then a−c=(k+l)na - c = (k + l)n. There are exactly nn classes, [0],[1],…,[n−1][0], [1], \dots, [n-1], one for each possible remainder, by Euclidean division (2A.1 The Natural Numbers).

The key fact about equivalence classes is that they cut XX into non-overlapping pieces.

Theorem 2.23 Equivalence classes partition the set

Let ∼\sim be an equivalence relation on XX. Then every element of XX lies in exactly one equivalence class. In particular, two classes [x][x] and [y][y] are either equal (when x∼yx \sim y) or disjoint (when x≁yx \not\sim y).

Conversely, any way of cutting XX into non-empty, pairwise disjoint pieces whose union is XX (a partition) comes from exactly one equivalence relation: "x∼yx \sim y when xx and yy are in the same piece".

Proof. Each xx lies in its own class, by reflexivity. Suppose [x][x] and [y][y] share an element zz, so z∼xz \sim x and z∼yz \sim y. By symmetry x∼zx \sim z, and with transitivity x∼yx \sim y. Now if w∈[x]w \in [x], then w∼xw \sim x and x∼yx \sim y give w∼yw \sim y, so w∈[y]w \in [y]; thus [x]⊆[y][x] \subseteq [y], and by the same argument [y]⊆[x][y] \subseteq [x]. So two classes that meet are equal, which is the first claim. The converse is a direct check of the three properties (Exercise 2.37).

Figure 2.4. Congruence modulo 33 on {0,…,11}\{0, \dots, 11\}. Its three equivalence classes are the three remainders, and they partition the set: every number lies in exactly one class.

Now the central construction.

Definition 2.24 Quotient set

Let ∼\sim be an equivalence relation on XX. The quotient set X/∼X/{\sim} is the set of equivalence classes, {[x]:x∈X}\{[x] : x \in X\}. The map π:X→X/∼\pi : X \to X/{\sim}, π(x)=[x]\pi(x) = [x], is the quotient map.

The quotient is a new set whose elements are whole classes. Each class is treated as a single object. The quotient map is always surjective, and it is injective only when ∼\sim is plain equality. It forgets exactly the differences that ∼\sim declares unimportant.

Figure 2.5. The quotient R/Z\mathbb{R}/\mathbb{Z}, where x∼yx \sim y when x−yx - y is an integer. Each class, such as {…,0.25,1.25,2.25,… }\{\dots, 0.25, 1.25, 2.25, \dots\}, becomes one point, and the quotient is naturally pictured as a circle: going once round it means moving one unit along the line.
In the world In use The antimeridian: a quotient that breaks software

Longitude is an angle: −180°-180° and +180°+180° name the same meridian, and so do 10°10° and 370°370°. Mathematically, longitude is a point of the quotient R/360Z\mathbb{R}/360\mathbb{Z}, a circle, not a point of the interval [−180,180][-180, 180]. Software that forgets this breaks at the antimeridian, the line of ±180°\pm 180° through the Pacific. A rectangle that runs from 170°170° E across to 170°170° W (that is, to −170°-170°) is only 20°20° wide. Stored naively as "from 170170 to −170-170", it is drawn as a band 340°340° wide stretching the wrong way round the whole globe. The GeoJSON format, a standard for exchanging map data (IETF RFC 7946, 2016), addresses this explicitly. Its section 3.1.9, Antimeridian Cutting, says that a geometry crossing the antimeridian should be cut in two, so that no piece's coordinates cross it.

Figure 2.6. The same 20°-wide region near the antimeridian, stored naively (top) and cut in two as RFC 7946 recommends (bottom). The underlying mistake is treating a quotient (a circle of longitudes) as if it were an interval.

Functions on a quotient must be well defined

To define a function on a quotient set X/∼X/{\sim}, it is natural to give a formula in terms of a representative: "F([x])F([x]) is something computed from xx". That defines a function only if the answer doesn't depend on which representative of the class you used. This condition is called being well defined.

Proposition 2.25 Defining functions on quotients

Let ∼\sim be an equivalence relation on XX, and let f:X→Yf : X \to Y be a function that is constant on each class: x∼x′x \sim x' implies f(x)=f(x′)f(x) = f(x'). Then there is exactly one function F:X/∼→YF : X/{\sim} \to Y with F([x])=f(x)F([x]) = f(x) for every xx, that is, with F∘π=fF \circ \pi = f.

Proof. Define FF on a class CC by choosing any x∈Cx \in C and setting F(C)=f(x)F(C) = f(x). Any other choice x′∈Cx' \in C satisfies x′∼xx' \sim x, so f(x′)=f(x)f(x') = f(x): the value doesn't depend on the choice, and FF is a function. It satisfies F([x])=f(x)F([x]) = f(x) by construction, and any function with that property must agree with FF on every class.

Example 2.26 A formula that isn't a function

On the clock Z/12\mathbb{Z}/12, "F([a])=aF([a]) = a" is not a function into the integers, because [3]=[15][3] = [15] but 3≠153 \neq 15. On the other hand, "G([a])=[a+5]G([a]) = [a + 5]" is a well-defined function Z/12→Z/12\mathbb{Z}/12 \to \mathbb{Z}/12 ("five hours later"): if a≡a′(mod12)a \equiv a' \pmod{12} then a+5≡a′+5(mod12)a + 5 \equiv a' + 5 \pmod{12}.

This is exactly why a clock can tell you what time it will be in five hours, but not how many hours have passed since a given moment. That last quantity isn't a function of the clock reading, which was the recursion problem of 2A.1 The Natural Numbers seen from a new angle.

Where this goes Quotients from here to Ricci flow

The pattern "build a set of representatives, declare an equivalence, check that operations are well defined" is how the next two chapters build numbers. The integers are pairs of naturals modulo an equivalence, and so are the rationals (2A.3 Integers and Rationals); the reals are Cauchy sequences modulo another (2A.4 The Real Numbers). Much later, the circle, tori and lens spaces are quotients of familiar spaces (7A.1 Topological Spaces and Quotients, 7A.7 Covering Spaces), and the 3-manifolds left behind by Ricci flow with surgery are quotients S3/ΓS^3/\Gamma of the sphere. Most striking of all, Ricci flow itself is diffeomorphism-invariant: changing coordinates turns a solution into a solution. So the flow really acts on the quotient set "metrics modulo diffeomorphisms", and much of its theory (DeTurck's trick, 11A.4 Short-Time Existence and Uniqueness; solitons, 11B.1 Ricci Solitons) is about working in that quotient.

Equivalence is a strong requirement

Transitivity is the property most often violated by relations that "feel like" sameness.

In the world In use "Similar enough" is not an equivalence relation

Merging duplicate records, such as customers entered twice under slightly different spellings, is a routine and expensive data-cleaning task. A natural rule is "two names are duplicates if they differ by at most one letter". This relation is reflexive and symmetric but not transitive. "cat" and "cot" differ in one letter, "cot" and "dot" in one, "dot" and "dog" in one, but "cat" and "dog" differ in all three. Merge along the rule and the chain cat–cot–dot–dog collapses into one record, though its two ends have nothing in common. Practical deduplication systems therefore either cluster with a careful threshold or make a final decision for each cluster. Either way, they must turn a non-transitive similarity into a genuine equivalence relation before they can form classes.

Figure 2.7. Each adjacent pair differs in one letter, but the ends differ in three. "Differs in at most one letter" is reflexive and symmetric, not transitive, so it can't be used to form classes. Chapter 2B.1 Metric Spaces studies such distances properly: the edit distance is a metric, and the issue here is that "distance at most 1" isn't transitive.

Working with quotients

Quotients are the most abstract idea in this chapter, and the next two chapters lean on them hard. This section collects the three facts you will use: every function defines an equivalence relation, every function factors through its quotient, and operations with two inputs can be passed to a quotient when they respect the equivalence.

Every function defines an equivalence relation

Proposition 2.27 The relation "same output"

Let f:X→Yf : X \to Y. The relation x∼fx′x \sim_f x' when f(x)=f(x′)f(x) = f(x') is an equivalence relation on XX. The class of xx is the fibre f−1({f(x)})f^{-1}(\{f(x)\}), the set of inputs with the same output as xx.

Proof. Reflexive, symmetric and transitive because equality is: f(x)=f(x)f(x) = f(x); if f(x)=f(x′)f(x) = f(x') then f(x′)=f(x)f(x') = f(x); if f(x)=f(x′)f(x) = f(x') and f(x′)=f(x′′)f(x') = f(x'') then f(x)=f(x′′)f(x) = f(x''). The class of xx is {x′:f(x′)=f(x)}\{x' : f(x') = f(x)\}, which is the preimage of the one-point set {f(x)}\{f(x)\}.

For example, "same remainder on division by 1212" is ∼f\sim_f for the function ff that sends aa to its remainder. "Same birthday" is ∼f\sim_f for the function sending a person to their birthday. In fact every equivalence relation arises this way: ∼\sim is the same as ∼π\sim_\pi for its own quotient map π\pi, since π(x)=π(x′)\pi(x) = \pi(x') means [x]=[x′][x] = [x'], which means x∼x′x \sim x' by Theorem 2.23.

Every function factors through a quotient

Theorem 2.28 Factoring a function through its quotient

Let f:X→Yf : X \to Y, and let ∼f\sim_f be the relation of Proposition 2.27. Then

F:X/∼f→f(X),F([x])=f(x)F : X/{\sim_f} \to f(X), \qquad F([x]) = f(x)

is a well-defined bijection, and f=ι∘F∘πf = \iota \circ F \circ \pi, where π:X→X/∼f\pi : X \to X/{\sim_f} is the quotient map and ι:f(X)→Y\iota : f(X) \to Y is the inclusion y↦yy \mapsto y.

Proof. Well defined: ff is constant on each class by definition of ∼f\sim_f, so Proposition 2.25 applies. Injective: if F([x])=F([x′])F([x]) = F([x']), then f(x)=f(x′)f(x) = f(x'), so x∼fx′x \sim_f x' and [x]=[x′][x] = [x']. Surjective: every element of f(X)f(X) is f(x)=F([x])f(x) = F([x]) for some xx. Finally, ι(F(π(x)))=f(x)\iota(F(\pi(x))) = f(x) for every xx.

Figure 2.8. Every function is a surjection onto a quotient, then a bijection, then an inclusion. The quotient forgets exactly what ff forgets, and nothing more.

Theorem 2.28 says that a function is always "a quotient, followed by a relabelling, followed by an inclusion". In words: the quotient of XX by "same output" is a perfect copy of the set of outputs. So a quotient is not as abstract as it looks. Whenever you have a function that is constant exactly on the classes, the quotient can be identified with that function's image. Three examples:

  • Z/12\mathbb{Z}/12 can be identified with {0,1,…,11}\{0, 1, \dots, 11\}, through "remainder on division by 12".
  • Longitudes R/360Z\mathbb{R}/360\mathbb{Z} can be identified with the points of a circle, through "the direction at angle xx degrees". (Making that map precise needs cos⁡\cos and sin⁡\sin, built in 2B.6 Power Series, Exponentials and Bump Functions.)
  • The rationals of 2A.3 Integers and Rationals, defined as a quotient of pairs of integers, can be identified with lowest-terms fractions, through "reduce to lowest terms".

So why define quotients at all, if they can be identified with images? Because often there is no convenient function to start from. The real numbers in 2A.4 The Real Numbers are defined as a quotient precisely because there is no set of "real numbers" yet to map to. The quotient creates the new set.

Operations on a quotient

The integers and rationals of 2A.3 Integers and Rationals need addition and multiplication on a quotient, which are functions of two inputs. The single-input rule Proposition 2.25 extends directly.

Proposition 2.29 Two-input operations on a quotient

Let ∼\sim be an equivalence relation on XX, and g:X×X→Xg : X \times X \to X a function with the property

x∼x′ and y∼y′  ⟹  g(x,y)∼g(x′,y′).x \sim x' \text{ and } y \sim y' \implies g(x, y) \sim g(x', y').

Then G([x],[y])=[g(x,y)]G([x], [y]) = [g(x, y)] defines a function G:(X/∼)×(X/∼)→X/∼G : (X/{\sim}) \times (X/{\sim}) \to X/{\sim}.

Proof. We must check that the value doesn't depend on the representatives chosen. If [x]=[x′][x] = [x'] and [y]=[y′][y] = [y'], then x∼x′x \sim x' and y∼y′y \sim y', so g(x,y)∼g(x′,y′)g(x, y) \sim g(x', y'), so [g(x,y)]=[g(x′,y′)][g(x, y)] = [g(x', y')].

The condition is often summarised as "gg respects ∼\sim". To check it, take representatives, change them to equivalent ones, and show the answer changes only to an equivalent one.

Example 2.30 Clock arithmetic is well defined

Fix n≥1n \geq 1, and on the integers let a≡b(modn)a \equiv b \pmod n as in Example 2.22. Define [a]+[b]=[a+b][a] + [b] = [a + b] and [a]⋅[b]=[ab][a] \cdot [b] = [ab] on Z/n\mathbb{Z}/n.

Addition respects ≡\equiv. If a′=a+kna' = a + kn and b′=b+lnb' = b + ln, then a′+b′=(a+b)+(k+l)na' + b' = (a + b) + (k + l)n, so a′+b′≡a+ba' + b' \equiv a + b.

Multiplication respects ≡\equiv. With the same a′,b′a', b':

a′b′=(a+kn)(b+ln)=ab+(al+bk+kln) n,a'b' = (a + kn)(b + ln) = ab + (al + bk + kln)\,n,

so a′b′≡aba'b' \equiv ab.

So Z/n\mathbb{Z}/n has a well-defined addition and multiplication. In Z/12\mathbb{Z}/12: [7]+[8]=[15]=[3][7] + [8] = [15] = [3] (seven hours after eight o'clock is three o'clock) and [5]⋅[5]=[25]=[1][5] \cdot [5] = [25] = [1].

Example 2.31 Casting out nines

Since 10=9+110 = 9 + 1, we have [10]=[1][10] = [1] in Z/9\mathbb{Z}/9. Because multiplication is well defined, [10k]=[10]k=[1]k=[1][10^k] = [10]^k = [1]^k = [1] for every kk. So for a number with decimal digits dk…d1d0d_k \dots d_1 d_0,

[dk10k+⋯+d110+d0]=[dk]+⋯+[d1]+[d0]in Z/9.[d_k 10^k + \dots + d_1 10 + d_0] = [d_k] + \dots + [d_1] + [d_0] \quad \text{in } \mathbb{Z}/9.

A number and the sum of its digits have the same remainder mod 99. This gives an old check on hand multiplication. For 37×41=151737 \times 41 = 1517: the digit sums are 10≡110 \equiv 1 and 55, whose product is 55; and 1+5+1+7=14≡51 + 5 + 1 + 7 = 14 \equiv 5. They agree, as they must. (A wrong answer can pass the check, if the error is a multiple of 99, but an answer that fails it is certainly wrong.)

Example 2.32 An operation that does not pass to the quotient

Try to define powers on Z/12\mathbb{Z}/12 by [a][b]=[ab][a]^{[b]} = [a^b]. Take a=2a = 2. Since [1]=[13][1] = [13], the definition would need [21]=[213][2^1] = [2^{13}]. But 21=22^1 = 2 and 213=8192=682×12+82^{13} = 8192 = 682 \times 12 + 8, so [213]=[8]≠[2][2^{13}] = [8] \neq [2]. The exponent does not respect congruence mod 1212, and the formula defines nothing. (Powers [a]k[a]^k with kk an ordinary natural number are fine: that is repeated multiplication, which is well defined.)

Recall Where we stand

We have the language of sets and functions, the four kinds of maps (injective, surjective, bijective, neither), images and preimages and why preimages behave better, products and relations, and the central tool of the next two chapters: equivalence relations, quotients and well-definedness. Every function factors as a quotient followed by a bijection onto its image, and operations that respect an equivalence pass to the quotient. Chapter 2A.3 Integers and Rationals uses all of it to build the integers and the rationals from the natural numbers.

Exercises

Exercise 2.33 A distributive law

Prove that A∩(B∪C)=(A∩B)∪(A∩C)A \cap (B \cup C) = (A \cap B) \cup (A \cap C) for any sets AA, BB, CC, by showing each side is a subset of the other.

Solution

If x∈A∩(B∪C)x \in A \cap (B \cup C) then x∈Ax \in A, and x∈Bx \in B or x∈Cx \in C. In the first case x∈A∩Bx \in A \cap B, in the second x∈A∩Cx \in A \cap C; either way xx is in the right-hand side. Conversely, if x∈A∩Bx \in A \cap B then x∈Ax \in A and x∈B⊆B∪Cx \in B \subseteq B \cup C, so xx is in the left-hand side; the case x∈A∩Cx \in A \cap C is the same.

Exercise 2.34 Composition and the kinds of maps

Let f:X→Yf : X \to Y and g:Y→Zg : Y \to Z. Prove: (a) if ff and gg are injective, so is g∘fg \circ f; (b) if ff and gg are surjective, so is g∘fg \circ f; (c) if g∘fg \circ f is injective, then ff is injective, but gg need not be.

Hint

For (c), a counterexample: let XX have one element, and let gg send two different points of YY to the same point.

Solution

(a) If g(f(x))=g(f(x′))g(f(x)) = g(f(x')), then f(x)=f(x′)f(x) = f(x') because gg is injective, and then x=x′x = x' because ff is injective. (b) Given z∈Zz \in Z, choose y∈Yy \in Y with g(y)=zg(y) = z, then x∈Xx \in X with f(x)=yf(x) = y; so g(f(x))=zg(f(x)) = z. (c) If f(x)=f(x′)f(x) = f(x'), then g(f(x))=g(f(x′))g(f(x)) = g(f(x')), so x=x′x = x' because g∘fg \circ f is injective. For the counterexample, let X={a}X = \{a\}, Y={p,q}Y = \{p, q\}, Z={z}Z = \{z\}, f(a)=pf(a) = p and g(p)=g(q)=zg(p) = g(q) = z. Then g∘fg \circ f has a one-element domain, so it is injective, but gg is not. (Similarly, if g∘fg \circ f is surjective then gg is surjective, but ff need not be.)

Exercise 2.35 When images behave

Show that if ff is injective then f(S∩T)=f(S)∩f(T)f(S \cap T) = f(S) \cap f(T) for all S,T⊆XS, T \subseteq X. Then find the exact place in your proof where injectivity is used, and check that Example 2.18 fails at that place.

Solution

The inclusion f(S∩T)⊆f(S)∩f(T)f(S \cap T) \subseteq f(S) \cap f(T) always holds (Proposition 2.17). For the reverse, let y∈f(S)∩f(T)y \in f(S) \cap f(T), so y=f(s)y = f(s) for some s∈Ss \in S and y=f(t)y = f(t) for some t∈Tt \in T. Then f(s)=f(t)f(s) = f(t), and injectivity gives s=ts = t, which lies in S∩TS \cap T; so y∈f(S∩T)y \in f(S \cap T). In Example 2.18, y=1y = 1 has s=−1∈Ss = -1 \in S and t=1∈Tt = 1 \in T with f(s)=f(t)f(s) = f(t) but s≠ts \neq t: exactly the step that fails.

Exercise 2.36 Going there and back

Let f:X→Yf : X \to Y, S⊆XS \subseteq X and U⊆YU \subseteq Y. Prove that S⊆f−1(f(S))S \subseteq f^{-1}(f(S)) and f(f−1(U))⊆Uf(f^{-1}(U)) \subseteq U. Show that the first inclusion is an equality for every SS exactly when ff is injective, and the second for every UU exactly when ff is surjective.

Solution

If x∈Sx \in S then f(x)∈f(S)f(x) \in f(S), so x∈f−1(f(S))x \in f^{-1}(f(S)). If y∈f(f−1(U))y \in f(f^{-1}(U)), then y=f(x)y = f(x) for some xx with f(x)∈Uf(x) \in U, so y∈Uy \in U.

Injective case. If ff is injective and x∈f−1(f(S))x \in f^{-1}(f(S)), then f(x)=f(s)f(x) = f(s) for some s∈Ss \in S, so x=s∈Sx = s \in S. Conversely, if ff is not injective, pick x≠x′x \neq x' with f(x)=f(x′)f(x) = f(x') and let S={x}S = \{x\}: then x′∈f−1(f(S))x' \in f^{-1}(f(S)) but x′∉Sx' \notin S.

Surjective case. If ff is surjective and y∈Uy \in U, pick xx with f(x)=yf(x) = y; then x∈f−1(U)x \in f^{-1}(U) and y∈f(f−1(U))y \in f(f^{-1}(U)). Conversely, if some yy is not an output, let U={y}U = \{y\}: then f−1(U)=∅f^{-1}(U) = \varnothing, so f(f−1(U))=∅≠Uf(f^{-1}(U)) = \varnothing \neq U.

Exercise 2.37 Partitions give equivalence relations

Complete the proof of Theorem 2.23: given a partition of XX, show that "x∼yx \sim y if xx and yy lie in the same piece" is an equivalence relation whose classes are exactly the pieces.

Solution

Reflexive: the pieces cover XX, so each xx lies in some piece, together with itself. Symmetric: "in the same piece" doesn't depend on the order. Transitive: if x,yx, y lie in a piece PP and y,zy, z in a piece QQ, then y∈P∩Qy \in P \cap Q; distinct pieces are disjoint, so P=QP = Q, and x,zx, z lie in the same piece. Classes: [x][x] is the set of yy in the same piece as xx, which is the piece containing xx. Only one relation: any equivalence relation whose classes are the pieces satisfies x∼yx \sim y exactly when y∈[x]y \in [x], that is, when yy is in the piece of xx.

Exercise 2.38 Element-chasing practice

Prove that A∖(B∪C)=(A∖B)∩(A∖C)A \setminus (B \cup C) = (A \setminus B) \cap (A \setminus C) and A∖(B∩C)=(A∖B)∪(A∖C)A \setminus (B \cap C) = (A \setminus B) \cup (A \setminus C). Then decide, with proof or counterexample, whether (A∪B)∖C=A∪(B∖C)(A \cup B) \setminus C = A \cup (B \setminus C).

Solution

x∈A∖(B∪C)x \in A \setminus (B \cup C) means x∈Ax \in A and not (x∈Bx \in B or x∈Cx \in C), that is, x∈Ax \in A, x∉Bx \notin B and x∉Cx \notin C, which is x∈(A∖B)∩(A∖C)x \in (A \setminus B) \cap (A \setminus C). The second identity is the same with "not (and)" becoming "or not". The third is false: with A=C={1}A = C = \{1\} and B=∅B = \varnothing, the left side is ∅\varnothing and the right side is {1}\{1\}. What is true is (A∪B)∖C=(A∖C)∪(B∖C)(A \cup B) \setminus C = (A \setminus C) \cup (B \setminus C).

Exercise 2.39 Power sets

List the elements of the power set of {1,2,3}\{1, 2, 3\}. Explain why adding one new element to a finite set doubles the number of its subsets, and deduce that a set with nn elements has 2n2^n subsets.

Solution

∅\varnothing, {1}\{1\}, {2}\{2\}, {3}\{3\}, {1,2}\{1,2\}, {1,3}\{1,3\}, {2,3}\{2,3\}, {1,2,3}\{1,2,3\}: eight. If A′=A∪{a}A' = A \cup \{a\} with a∉Aa \notin A, each subset of A′A' either omits aa (and is a subset of AA) or contains aa (and is S∪{a}S \cup \{a\} for exactly one subset SS of AA). So A′A' has twice as many subsets as AA, and induction on nn gives 2n2^n, starting from the one subset ∅\varnothing of ∅\varnothing. This is why 2A2^A is a common notation for the power set. Counting finite sets properly is the business of 2A.8 Infinite Sets.

Exercise 2.40 Fibres of the squaring map

For s:R→Rs : \mathbb{R} \to \mathbb{R}, s(x)=x2s(x) = x^2, describe the classes of ∼s\sim_s (Proposition 2.27), and the bijection FF of Theorem 2.28. Then do the same for p:R2→Rp : \mathbb{R}^2 \to \mathbb{R}, p(x,y)=x2+y2p(x, y) = x^2 + y^2.

Solution

For ss, the class of xx is {x,−x}\{x, -x\} (just {0}\{0\} when x=0x = 0), and FF sends the class {x,−x}\{x, -x\} to x2∈[0,∞)x^2 \in [0, \infty). The quotient "identifies xx with −x-x", and FF says this quotient is a copy of [0,∞)[0, \infty), the half-line. For pp, the classes are the circles centred at the origin (and the origin itself), and FF sends each circle to the square of its radius, again identifying the quotient with [0,∞)[0, \infty). The second example is a first glimpse of how quotients by symmetries are used: functions on the plane that are unchanged by rotation are the same thing as functions of the radius alone.

Exercise 2.41 Casting out nines, and elevens

(a) Use Example 2.31 to show without dividing that 123,456,789123{,}456{,}789 is a multiple of 99. (b) Show that [10]=[−1][10] = [-1] in Z/11\mathbb{Z}/11, and deduce that a number has the same remainder mod 1111 as the alternating sum of its digits d0−d1+d2−⋯d_0 - d_1 + d_2 - \cdots. Check it on 1517=37×411517 = 37 \times 41.

Solution

(a) The digit sum is 1+2+⋯+9=45=5×91 + 2 + \cdots + 9 = 45 = 5 \times 9, so the number is ≡0(mod9)\equiv 0 \pmod 9. (b) 10=11−110 = 11 - 1, so [10]=[−1][10] = [-1] and [10k]=[−1]k[10^k] = [-1]^k, which is [1][1] for even kk and [−1][-1] for odd kk. So the number is congruent to d0−d1+d2−⋯d_0 - d_1 + d_2 - \cdots. For 15171517: 7−1+5−1=107 - 1 + 5 - 1 = 10, and 37×41≡4×8=32≡10(mod11)37 \times 41 \equiv 4 \times 8 = 32 \equiv 10 \pmod{11}, since 37=3×11+437 = 3 \times 11 + 4 and 41=3×11+841 = 3 \times 11 + 8. They agree.

Exercise 2.42 Which are equivalence relations?

For each relation, decide whether it is reflexive, symmetric and transitive: (a) m≤nm \leq n on N\mathbb{N}; (b) "x−yx - y is an even integer" on Z\mathbb{Z}; (c) "∣x−y∣<1|x - y| < 1" on R\mathbb{R}; (d) "lives within 10 km of" on the set of people; (e) "xx and yy have the same last digit" on N\mathbb{N}.

Solution

(a) Reflexive and transitive, not symmetric. (b) An equivalence relation, with two classes, the even and odd integers. (c) Reflexive and symmetric, not transitive (0∼0.6∼1.20 \sim 0.6 \sim 1.2 but ∣0−1.2∣>1|0 - 1.2| > 1): the real-number version of "similar enough". (d) Same as (c). (e) An equivalence relation with ten classes; it is congruence modulo 1010.

Exercise 2.43 Well defined or not?

On Z/12\mathbb{Z}/12 (clock arithmetic), decide which of these formulas define functions: (a) [a]↦[2a][a] \mapsto [2a] into Z/12\mathbb{Z}/12; (b) [a]↦[a][a] \mapsto [a] into Z/6\mathbb{Z}/6; (c) [a]↦[a][a] \mapsto [a] into Z/5\mathbb{Z}/5; (d) [a]↦[a] \mapsto the remainder of aa on division by 1212, into {0,…,11}\{0, \dots, 11\}.

Solution

(a) Yes: a≡a′(mod12)a \equiv a' \pmod{12} gives 2a≡2a′(mod12)2a \equiv 2a' \pmod{12}. (b) Yes: a multiple of 1212 is a multiple of 66, so congruent mod 1212 implies congruent mod 66. (c) No: [0]=[12][0] = [12] in Z/12\mathbb{Z}/12, but 0≢12(mod5)0 \not\equiv 12 \pmod 5. (d) Yes, and it is a bijection: it chooses one canonical representative for each class.

Exercise 2.44 Rehearsal: a distance on a circle

Longitudes live in R/360Z\mathbb{R}/360\mathbb{Z}. Show that d([a],[b])=min⁡{∣a−b−360k∣:k∈Z}d([a], [b]) = \min\{|a - b - 360k| : k \in \mathbb{Z}\} is well defined, that is, independent of the representatives aa and bb, and compute d([170],[−170])d([170], [-170]). This is the first appearance of a recurring idea: a quotient often inherits a distance from the space above it, by taking the shortest distance between classes. Riemannian quotients such as lens spaces get their geometry the same way (7A.7 Covering Spaces, 9A.1 Riemannian Metrics and Model Spaces).

Solution

Replacing aa by a+360ja + 360j changes the set {∣a−b−360k∣:k∈Z}\{|a - b - 360k| : k \in \mathbb{Z}\} only by renaming kk to k−jk - j, so the minimum is unchanged; the same holds for bb. For a=170a = 170, b=−170b = -170: a−b=340a - b = 340, and ∣340−360∣=20|340 - 360| = 20 is the smallest value, so the distance is 20°20°, as the map in Figure 2.6 says it should be.

Free resources for this chapter

Chosen for what this chapter covers, and all free to read or watch. Where a lecture covers more than this chapter, the minutes to watch are given, and the link starts there when it can. Links checked Nov 6, 2026.

Read

Watch 3 lectures and talks

© 2026 Neckpinch (www.neckpinch.com). All content in the guidebook (text, mathematics, figures and exercises) is protected by copyright. All rights reserved. No part may be copied, republished or redistributed without written permission.