© 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.
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]].
In this chapter · 6 sections
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 set identities;
- 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.
Sets
A set is a collection of objects, called its elements. We write when is an element of , and when it isn't. A set is completely determined by its elements: two sets are equal exactly when they have the same elements. So , and are the same set. Order and repetition don't matter, only membership.
A set is a subset of a set , written , if every element of is also an element of . It is a proper subset, written , if in addition .
Equality of sets is then the same as inclusion both ways: if and only if and . 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 with no elements.
- For any objects and there are the sets and .
- For any sets and there is the union , whose elements are those that lie in or in (or both).
- Specification. For any set and any property , there is a set of the elements of that have the property.
- Replacement. For any set and any rule assigning an object to each , there is a set .
- Infinity. The natural numbers form a set.
- Power set. For any set 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 with property " with no ambient set, and the reason is one of the most famous arguments in mathematics.
Suppose any property defined a set. Consider the property " is a set that is not an element of itself", and let be the set of all such . Is an element of itself? If , then has the defining property, so . If , then has the property, so . 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
Let and be sets.
- The intersection consists of the elements in both.
- The difference consists of the elements of not in .
- and are disjoint if .
When all the sets in a discussion are subsets of one fixed set , the difference is called the complement of (in ), written .
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.
Let and be subsets of a set . Then
More generally, for any family of subsets of , indexed by in some set ,
Proof. We prove the first law for a family; the others are the same argument. Let . Then lies in the left-hand side exactly when is not in , that is, when there is no with . That says for every , which means for every , 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 with …)" became "for every , 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.
Functions
Informally, a function from to is a rule that takes each element of and returns an element of . The precise definition makes three things part of the data: where inputs come from, where outputs land, and the rule.
Let and be sets. A function assigns to every exactly one element . The set is the domain of , and is its codomain. Two functions are equal if for every .
Three consequences of the definition catch people out.
- Every input gets an output. " from to " is not a function, because gets nothing. It becomes one if the domain is .
- Exactly one output. "$f(y) = $ the number whose square is " is not a function on the positive reals, because has two square roots. Choosing one ("the positive square root") makes it a function.
- Equality is about values, not formulas. and are the same function. On the other hand, as a function and as a function 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 . A function is its graph: a set of pairs in which every appears as a first entry exactly once. Pairs need one more construction, the Cartesian product, which comes later in this chapter.
Composition. If and , the composition is . Composition is associative, , because both send to . It is not commutative: putting on socks and then shoes is not the same as shoes then socks.
Injective, surjective, bijective
A function is
- injective (one-to-one) if different inputs give different outputs: implies ;
- surjective (onto) if every element of is an output: for every there is some with ;
- bijective if it is both.
You met injectivity already: 2A.1 The Natural Numbers's Axiom 1.4 says exactly that the successor map is injective. Together with Axiom 1.3 ( is not a successor), it says that the successor map from to is injective but not surjective.
A function is bijective if and only if there is a function with for every and for every . Such a is unique; it is the inverse of , written .
Proof. If is bijective, then for each there is some with (surjectivity), and only one (injectivity). Define to be that . Then by construction, and because is the unique input sent to .
Conversely, suppose such a exists. If , apply : , so is injective. Given , the element satisfies , so is surjective.
For uniqueness, if and both work, then for every , , using and then with .
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 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.
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, with letters numbered to and wrapping round after (exactly the clock arithmetic of 2A.1 The Natural Numbers). Its inverse is . Modern block ciphers such as AES are, for each key, bijections on the set of 128-bit blocks. Decryption is the inverse function.
Images and preimages
A function moves sets as well as points. There are two directions, and they behave very differently.
Let .
- For , the image of is , the set of outputs of inputs from .
- For , the preimage (or inverse image) of is , the set of inputs whose outputs land in .
The notation does not require to have an inverse. It makes sense for every function. If on , then , , and .
Preimages respect every set operation. Images don't.
Let , and let and (for ) be subsets of . Then
Proof. For the union: means for some , which means for some , which is membership of the right-hand side. The intersection is the same with "some" replaced by "every". For the complement: means , which means .
For images, only the union rule survives: always, but in general can happen.
Let on , and . Then , so . But , so . Points from and points from are sent to the same place, so after applying you can no longer tell them apart. If is injective this can't happen, and then (Exercise 2.20).
Theorem 2.8 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.
A greyscale photograph is a function from the set of pixels to brightness values . "Select every pixel brighter than ", the first step in many image-segmentation tools and in counting stars, cells or defects in a picture, is the preimage . Theorem 2.8 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
An ordered pair consists of a first entry and a second entry ; two pairs are equal exactly when their first entries are equal and their second entries are equal. The Cartesian product of sets and is the set of all ordered pairs . Products of more sets, , consist of ordered -tuples.
So is the plane, and a function can be identified with its graph, a subset of . If has elements and has , then has , which is where the word "product" comes from.
A relation on a set is a subset . We write for .
"Less than" on is a relation: the set of pairs with . So is "has the same birthday as" on the set of people.
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.10, 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 " is one: it treats , and as the same as far as a clock is concerned. Three properties capture what "behaves like equality" means.
A relation on a set is an equivalence relation if it is
- reflexive: for every ;
- symmetric: if then ;
- transitive: if and then .
The equivalence class of is , everything equivalent to .
Fix a positive natural number . For integers and , say if is a multiple of . (We use the integers informally here; they are built properly in 2A.3 Integers and Rationals.) This is an equivalence relation: ; if then ; and if and then . There are exactly classes, , one for each possible remainder, by Euclidean division (2A.1 The Natural Numbers).
The key fact about equivalence classes is that they cut into non-overlapping pieces.
Let be an equivalence relation on . Then every element of lies in exactly one equivalence class. In particular, two classes and are either equal (when ) or disjoint (when ).
Conversely, any way of cutting into non-empty, pairwise disjoint pieces whose union is (a partition) comes from exactly one equivalence relation: " when and are in the same piece".
Proof. Each lies in its own class, by reflexivity. Suppose and share an element , so and . By symmetry , and with transitivity . Now if , then and give , so ; thus , and by the same argument . So two classes that meet are equal, which is the first claim. The converse is a direct check of the three properties (Exercise 2.22).
Now the central construction.
Let be an equivalence relation on . The quotient set is the set of equivalence classes, . The map , , 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 is plain equality. It forgets exactly the differences that declares unimportant.
Longitude is an angle: and name the same meridian, and so do and . Mathematically, longitude is a point of the quotient , a circle, not a point of the interval . Software that forgets this breaks at the antimeridian, the line of through the Pacific. A rectangle that runs from E across to W (that is, to ) is only wide. Stored naively as "from to ", it is drawn as a band 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.
Functions on a quotient must be well defined
To define a function on a quotient set , it is natural to give a formula in terms of a representative: "$F([x]) = $ something computed from ". 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.
Let be an equivalence relation on , and let be a function that is constant on each class: implies . Then there is exactly one function with for every , that is, with .
Proof. Define on a class by choosing any and setting . Any other choice satisfies , so : the value doesn't depend on the choice, and is a function. It satisfies by construction, and any function with that property must agree with on every class.
On the clock , "" is not a function into the integers, because but . On the other hand, "" is a well-defined function ("five hours later"): if then .
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.
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.6 Covering Spaces), and the 3-manifolds left behind by Ricci flow with surgery are quotients 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.3 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.
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.
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. Chapter 2A.3 Integers and Rationals uses all of it to build the integers and the rationals from the natural numbers.
Exercises
Prove that for any sets , , , by showing each side is a subset of the other.
Solution
If then , and or . In the first case , in the second ; either way is in the right-hand side. Conversely, if then and , so is in the left-hand side; the case is the same.
Let and . Prove: (a) if and are injective, so is ; (b) if and are surjective, so is ; (c) if is injective, then is injective, but need not be.
Hint
For (c), a counterexample: let have one element, and let send two different points of to the same point.
Show that if is injective then for all . Then find the exact place in your proof where injectivity is used, and check that Example 2.9 fails at that place.
Let , and . Prove that and . Show that the first inclusion is an equality for every exactly when is injective, and the second for every exactly when is surjective.
Complete the proof of Theorem 2.14: given a partition of , show that " if and lie in the same piece" is an equivalence relation whose classes are exactly the pieces.
For each relation, decide whether it is reflexive, symmetric and transitive: (a) on ; (b) " is an even integer" on ; (c) "" on ; (d) "lives within 10 km of" on the set of people; (e) " and have the same last digit" on .
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 ( but ): the real-number version of "similar enough". (d) Same as (c). (e) An equivalence relation with ten classes; it is congruence modulo .
On (clock arithmetic), decide which of these formulas define functions: (a) into ; (b) into ; (c) into ; (d) the remainder of on division by , into .
Solution
(a) Yes: gives . (b) Yes: a multiple of is a multiple of , so congruent mod implies congruent mod . (c) No: in , but . (d) Yes, and it is a bijection: it chooses one canonical representative for each class.
Longitudes live in . Show that is well defined, that is, independent of the representatives and , and compute . 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.6 Covering Spaces, 9A.1 Riemannian Metrics and Model Spaces).
Solution
Replacing by changes the set only by renaming to , so the minimum is unchanged; the same holds for . For , : , and is the smallest value, so the distance is , as the map in Figure 2.6 says it should be.
© 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.