Sets, relations, and functions — the language of mathematics
Anchor (Master): Halmos 1960 Naive Set Theory (Van Nostrand) §§1–7; Enderton 1977 Elements of Set Theory (Academic Press) Ch. 1–6 (full proofs)
Intuition Beginner
Mathematics has a grammar, just as English does. Three families of words do most of the work, and this unit teaches them together.
A set is a collection. Your pencil case is a set of pens. The days of the week are a set of seven names. A set gathers distinct things and treats them as a single object, so we can reason about the whole collection at once.
A relation is a way things can be connected. "Is taller than" links two people. "Has the same birthday month as" links other pairs. A relation lists which pairs are linked and which are not, nothing more.
A function is a dependable rule. Each input gives exactly one output. Doubling, squaring, and "add three" are functions. You met functions in the previous unit; here we widen the lens to the whole grammar that surrounds them.
Why care? Because nearly every idea in mathematics is built from these three notions. A vector space is a set with structure. A group is a set with a function. An equation asks when two functions agree. Learn these words now and every later unit reads more smoothly.
Visual Beginner
Three overlapping circles show how sets combine. The shaded region is the answer to each operation.
The four set operations in one table, using and :
| Operation | In words | Result |
|---|---|---|
| Union | everything in either | |
| Intersection | only what is in both | |
| Difference | in but not in | |
| Complement | everything not in | depends on the universe |
Worked example Beginner
This is the deep idea of the unit, made small enough to hold in your hand.
Take the nine numbers . Link two numbers when they leave the same remainder after division by . Then sort the nine numbers by their remainder:
- Remainder : the numbers
- Remainder : the numbers
- Remainder : the numbers
The nine numbers fall into three non-overlapping groups. Every number lands in exactly one group. Together the three groups rebuild the whole set, with nothing left over and nothing counted twice.
This is called a partition. The link "same remainder by " is an equivalence relation, and its three groups are its equivalence classes. A partition and an equivalence relation are two views of the same structure. That single sentence is the heart of the unit.
Check your understanding Beginner
Formal definition Intermediate+
A set is a collection of distinct objects called its elements, written when belongs to . The set with no elements is the empty set . A set is a subset of , written , when every element of also lies in . The power set is the set of all subsets of .
Fix a universal set containing both and . The four operations combine sets as follows:
De Morgan's laws tie these operations together: and . They express the symmetry between "or" and "and" under negation [Enderton].
The Cartesian product of and bundles one element from each into an ordered pair:
Order matters: in general, and in general. The product is the substrate on which relations and functions are built.
A relation from to is a subset . When we write . A relation on a single set is a subset of . Four properties recur throughout mathematics. A relation on is:
- reflexive if for every ;
- symmetric if implies ;
- antisymmetric if and together imply ;
- transitive if and together imply .
A relation that is reflexive, symmetric, and transitive is an equivalence relation, conventionally written . An equivalence relation generalises equality: two related elements are "the same" for whatever purpose encodes. A partition of is a family of non-empty, pairwise disjoint subsets of whose union is all of .
A function , recalled from 00.02.05, is a relation in which each occurs in exactly one pair . The set is the domain, the codomain. A function is injective if distinct inputs give distinct outputs, surjective if every element of is hit, and bijective if it is both. The composition of after is .
Key theorem with proof Intermediate+
Theorem (equivalence relations and partitions). Let be a non-empty set. Every equivalence relation on determines a unique partition of , and every partition of determines a unique equivalence relation. These two constructions are mutually inverse.
Proof. Given an equivalence relation on , define the equivalence class of by
Each class is non-empty, because reflexivity gives , so . Since every element lies in its own class, the union of all classes is . It remains to show that two classes are either identical or disjoint.
Suppose two classes meet: . Choose , so and . By symmetry , and by transitivity together with gives . Now if , then and give , so ; this shows . The reverse inclusion follows by the same argument with and swapped. Hence whenever the classes meet, so distinct classes are disjoint. The classes therefore form a partition.
Conversely, given a partition of , define when and lie in the same part . Reflexivity holds because lies in exactly one part. Symmetry holds because equality of parts is symmetric. Transitivity holds because if and share a part and and share a part, that part is the same (the parts are disjoint), so and share it. The two constructions undo each other: the classes of the relation induced by a partition are exactly the original parts.
This bijection is the load-bearing result of the unit: to specify an equivalence relation is precisely to specify a partition, and conversely.
Bridge. This theorem builds toward the quotient constructions of linear algebra 01.01.03 and group theory 01.02.01, where a subspace or a normal subgroup defines an equivalence relation and the classes themselves become the elements of a new algebraic object. The same partition idea appears again in the construction of the integers from pairs of natural numbers, the rationals from pairs of integers, and the real numbers from Cauchy sequences of rationals. The central insight is that "declaring equivalent elements equal" is a single operation that generalises across algebra, topology, and analysis: putting these together, the bridge is that every quotient space, every modular arithmetic, and every isomorphism theorem is an equivalence relation wearing the costume of its field.
Exercises Intermediate+
Lean formalization Intermediate+
This unit ships with lean_status: none. The precalculus layer is prose-elementary: the quality gate is the worked-example exposition and the partition–equivalence-relation proof, not a Lean formalization. The underlying objects are nevertheless fully formalisable in Mathlib, and a companion module would make the bridge concrete.
In Mathlib, set operations live in the Set namespace (Set.union, Set.inter, Set.diff, Set.compl, Set.powerset), Cartesian products in Set.prod, and bijections in Equiv with composition and inverses built in. Equivalence relations are captured by Setoid together with Quotient, and the correspondence between equivalence relations and partitions is available through Setoid.quotient and supporting lemmas about classes. A future companion module under Codex.Precalc.SetAndFunction could port the mod-3 worked example and the congruence-mod-5 exercise into Lean, mirroring the formal treatment already shipped in 00.02.05.
Advanced results Master
The power set collects every subset of . For a finite set with elements, , so the power set is always larger than itself. Cantor's cornerstone result says this growth never stops, even for infinite sets: no set is in bijection with its own power set.
Theorem (Cantor). For every set , there is no surjection . Consequently .
The argument is short and diagonal. Given any function , form the set , which is itself an element of . If for some , then asking whether belongs to produces the contradiction . So escapes the image of , and was never surjective. The full proof appears in the proof set below. Cantor's theorem is the engine of the hierarchy of infinite cardinals and the seed of the undecidability results studied much later in the curriculum.
A second master-level theme is the lattice of partitions. The set of all equivalence relations on is partially ordered by refinement: write when every -class is contained in a -class, that is, when implies . Under this order the equivalence relations form a lattice. The meet of two relations is their intersection; the join is the transitive closure of their union (equivalently, the smallest equivalence relation containing both). The least element is equality, the finest partition into singletons; the greatest element is the universal relation , the coarsest partition with one class. This lattice is the backbone of every quotient construction across algebra, and the same shape reappears for subgroups, subspaces, and topologies.
The Cantor–Bernstein–Schröder theorem supplies the cardinality comparison test: if there is an injection and an injection , then there is a bijection . Stated without proof here, it lets us compare infinite sizes without ever constructing an explicit bijection, and together with Cantor's theorem it organises the infinite cardinals into a linear hierarchy.
Synthesis. Sets, relations, and functions are the grammar of mathematics, and this unit assembles them into a single working language. Sets collect the objects under study; relations describe how those objects stand to one another; functions are the special single-valued relations that transform one structure into another. Equivalence relations generalise the notion of equality, and the foundational reason quotients exist is that every equivalence relation partitions its set; the central insight of modern algebra is that these partitions inherit structure from the parent. This is exactly the mechanism behind quotient groups, quotient vector spaces, and the classification of objects up to isomorphism. The function concept builds toward category theory, where functions are the morphisms and bijections measure cardinality, and Cantor's theorem generalises into the hierarchy of infinite sizes that underpins all of set-based mathematics. Putting these together, the bridge is that the entire categorical and algebraic framework of the curriculum rests on these three primitives — collections, connections, and structure-preserving maps — and every later unit, from topology to measure theory to algebraic geometry, is written in this language.
Full proof set Master
Proposition (Cantor, full proof). For every set , there is no surjection , and therefore .
Proof. Let be any function. Define the diagonal set
Because , we have . Suppose, towards a contradiction, that is surjective. Then for some . Ask whether lies in :
- If , then by the definition of we have , a contradiction.
- If , then , so by the definition of we have , again a contradiction.
Both cases fail, so no such exists. The set lies outside the image of , so is not surjective. Because was arbitrary, no surjection exists, and the inclusion sending shows strictly.
Proposition (partitions form a lattice). The equivalence relations on a set , ordered by refinement, form a lattice with greatest element the universal relation and least element equality.
Proof. Let denote the set of all equivalence relations on . For , declare when every -class is contained in a -class, equivalently when implies . This relation is reflexive, antisymmetric, and transitive on , so it is a partial order.
The universal relation relates every pair of elements, so for every ; it is the greatest element, the single-class partition. The equality relation is the finest partition, with for every ; it is the least element.
For the meet, take as a subset of . It is reflexive, symmetric, and transitive (each property is checked pointwise), so it is an equivalence relation, and it is the greatest lower bound of and . For the join, take the transitive closure of : declare when there is a finite chain with each consecutive pair in or . This is the smallest equivalence relation containing both and , hence the least upper bound. Meets and joins of arbitrary families are constructed the same way, so is a complete lattice.
Connections Master
Equivalence relations and partitions are the engine of quotient vector spaces
01.01.03. A subspace defines when , and the resulting classes form a new vector space whose dimension drops by . The construction is the partition theorem of this unit with linear structure layered on top.In group theory
01.02.01, a normal subgroup defines when , and the classes form the quotient group . This is the same partition machinery, now carrying an inherited group operation, and the first isomorphism theorem identifies with the image of any homomorphism killing .Bijections define cardinality and reappear wherever counting matters, from the characteristic functions of probability
37.03.01to the cardinal arithmetic that sizes function spaces. Cantor's theorem proved here launches the hierarchy those later units measure with.Continuous maps
02.01.02are functions that preserve topological closeness, refining the bare set-theoretic function of this unit into a morphism of a category; the function concept is the seed, and continuity is the extra condition that makes it a geometric object.
Historical & philosophical context Master
Georg Cantor founded set theory in a sequence of papers beginning in 1874 with "Über eine Eigenschaft des Inbegriffes aller reellen algebraischen Zahlen," in which he proved that the real numbers cannot be put in bijection with the natural numbers [Cantor 1874]. The result shattered the earlier assumption that all infinite collections have the same size, and it forced mathematicians to treat collections of objects as legitimate objects of study in their own right. The controversy Cantor provoked among his contemporaries shaped the foundations debate of the early twentieth century.
Augustus De Morgan codified the symmetry between "or" and "and" under negation in his work on formal logic from 1858. The two identities and now bear his name and appear wherever boolean reasoning does, from circuit design to probability to the algebra of subsets studied here [Enderton].
Paul Halmos's Naive Set Theory (1960) distilled the working mathematician's set theory into a slender volume that remains the standard gentle introduction, treating sets, relations, functions, and equivalence classes with the informal precision this curriculum adopts at the Beginner and Intermediate tiers [Halmos]. Herbert Enderton's Elements of Set Theory (1977) gives the rigorous undergraduate treatment, including the partition–equivalence-relation correspondence and the construction of the number systems upward from the empty set.
Bibliography Master
@book{Halmos1960NaiveSetTheory,
author = {Halmos, Paul R.},
title = {Naive Set Theory},
publisher = {D. Van Nostrand},
year = {1960}
}
@book{Enderton1977ElementsOfSetTheory,
author = {Enderton, Herbert B.},
title = {Elements of Set Theory},
publisher = {Academic Press},
year = {1977}
}
@book{StewartRedlinWatson2016Precalculus,
author = {Stewart, James and Redlin, Lothar and Watson, Saleem},
title = {Precalculus: Mathematics for Calculus},
edition = {7},
publisher = {Cengage Learning},
year = {2016}
}
@article{Cantor1874,
author = {Cantor, Georg},
title = {Über eine Eigenschaft des Inbegriffes aller reellen algebraischen Zahlen},
journal = {Journal für die reine und angewandte Mathematik (Crelle's Journal)},
volume = {77},
pages = {258--262},
year = {1874}
}
@book{DeMorgan1858FormalLogic,
author = {De Morgan, Augustus},
title = {The Syllabus of a Proposed System of Logic},
publisher = {Walton and Maberly},
year = {1858}
}