Part VIII · Foundations Chapter 51 of 60
Logic and sets
For fifty chapters we’ve said ‘for every’, ‘there exists’, ‘therefore’ and ‘set’ without looking at the grammar. We’ll learn it on an island where some inhabitants always tell the truth and others always lie.
Builds on: 50 · Markov chains and information
You will learn
- build truth tables and check whether two formulas are equivalent
- negate statements with quantifiers correctly, including the definition of a limit
- recognise the kinds of proof: contrapositive, contradiction, induction, construction and counterexample
- tell injections, surjections and bijections apart and split a set into equivalence classes
- explain Russell’s paradox and why mathematics needed the ZFC axioms
For fifty chapters in a row we’ve been proving theorems without once asking what the word itself means. We wrote “for every $\varepsilon > 0$ there’s a $\delta$”, “the set of values”, “infinitely many primes”, “therefore”, and the last chapter measured information in “yes” or “no” answers. All this worked the way your native language works: you use it without opening a grammar book.
But a native language has habits that don’t suit mathematics. “Tea or coffee?” on a plane offers one of the two, while in a notice saying “discount for students or pensioners” a student who is also a pensioner doesn’t lose the discount. “All the students passed” sometimes means “almost all”. The language of mathematics needs every sentence to have exactly one meaning, and every argument to be checkable for correctness. That’s the grammar we’ll learn, and we’ll practise on an island invented by the American logician and magician Raymond Smullyan in his book What Is the Name of This Book? (1978).
The island of knights and knaves
The island has two kinds of inhabitants. Knights always tell the truth, knaves always lie. You can’t tell them apart by looking. You meet two of them, $A$ and $B$, and $A$ says: “At least one of us is a knave.” Who is who?
Let’s go through the cases. Suppose $A$ is a knave. Then his words are false, that is, there are no knaves among them and both are knights, including $A$ himself. A contradiction: $A$ can’t be both a knave and a knight. So $A$ is a knight. Then his words are true, and there is a knave among the two. Since it isn’t $A$, it’s $B$. Answer: $A$ is a knight, $B$ a knave.
We went through the possible worlds and threw out the one that contradicts itself: the two main operations of this chapter. An islander’s words are either true or false, and an inhabitant’s type must match the truth of what they say.
A statement (or proposition) is a sentence that is either true or false, and exactly one of the two. “Seven is a prime number” is a true statement, “$2 + 2 = 5$” a false one. “Every even number greater than two is a sum of two primes” is also a statement, though nobody yet knows whether it’s true (Goldbach’s conjecture). But “What time is it?” and “$x > 3$” aren’t statements: the first asserts nothing, and the second becomes true or false only when we’re told what $x$ is.
There’s a sentence on the island that nobody can say: “I am a knave.” A knight saying it would be lying, and a knave would be telling the truth. Such sentences are neither true nor false, and they’re kept out of the world of statements. Remember this sentence: at the end of the chapter it will come back and nearly bring down the whole of mathematics.
There are three inhabitants. $A$ says: “We are all knaves.” $B$ says: “Exactly one of us is a knight.” $C$ says nothing. How many knights are there among them?
$A$ can’t be a knight: then his words “we are all knaves” would be true, and he’d be a knave. So $A$ is a knave, his words are false, and there’s at least one knight among the three. If $B$ were a knave, the only knight would be $C$: exactly one, and $B$’s words would be true. A contradiction, so $B$ is a knight, and there’s exactly one knight among the three: $C$ is a knave. Answer: one knight. Check it in the widget by building this island on the “Your own island” tab.
Lesson one: not, and, or
Compound statements are built from simple ones with connective words, which logicians have agreed to understand strictly and write as symbols. The negation $\lnot A$ (“not $A$”) is true when $A$ is false. The conjunction $A \land B$ (“$A$ and $B$”) is true when both are true. The disjunction $A \lor B$ (“$A$ or $B$”) is true when at least one of the two is true, including when both are. This is the “or” of the discount notice, not of the plane; for “exactly one of the two” there’s a separate connective, exclusive “or”, $A \oplus B$.
The truth of a compound statement depends only on the truth of its parts, so a connective is completely described by a table of all the combinations. We’ll write truth as T and falsehood as F.
| $A$ | $B$ | $\lnot A$ | $A \land B$ | $A \lor B$ | $A \oplus B$ |
|---|---|---|---|---|---|
| T | T | F | T | T | F |
| T | F | F | F | T | T |
| F | T | T | F | T | T |
| F | F | T | F | F | F |
The truth table of a formula is a list of all the assignments of values to its variables with the value of the formula for each. A formula with $n$ variables has $2^n$ rows: each variable is T or F independently of the others. Two formulas are equivalent if their tables coincide; we write $F \equiv G$. A formula true in every row of its table is called a tautology.
The symbol $\equiv$ isn’t a connective inside a formula but our statement about two formulas. The simplest tautology is $A \lor \lnot A$, the law of the excluded middle: every statement is true or false. The second famous law answers a question that comes up in any argument: what does it mean for someone to be wrong when they said “or”?
For any statements $A$ and $B$
The trick is that a truth table is finite: by checking four rows we’ve checked every possible case at once.
Checking with a table is completely mechanical, and it’s better left to a machine. Type in two formulas: the widget will build the tables, say whether the formulas are equivalent, and if not, show a row where they differ.
& is “and”, | is “or”, ! is “not”, -> is “implies”. On the right is the same formula drawn with Euler circles: each region is one row of the table. Tap a row or a region.The circles next to the table aren’t decoration. Two circles have exactly four regions (inside both, only in the first, only in the second, outside) just as the table has four rows, and three circles have eight regions, as many as a formula with three variables has rows. This coincidence will come in handy when we get to sets.
Lesson two: if…, then…
The trickiest connective is “if…, then…”. Take a promise: “If it rains tomorrow, I’ll take an umbrella.” When is it broken? Only if it rained and there’s no umbrella. If it doesn’t rain, the promise required nothing, and it can’t be broken, whatever the person does with the umbrella.
The implication $A \to B$ (“if $A$ then $B$”, “$A$ implies $B$”) is false in only one row of the table: when $A$ is true and $B$ is false. $A$ is called the hypothesis (or premise), $B$ the conclusion. One also says that $A$ is a sufficient condition for $B$, and $B$ a necessary condition for $A$.
The rows with a false hypothesis are the most confusing: “if $2 + 2 = 5$, then the Moon is made of cheese” is a true statement. Logicians say: from a falsehood anything follows. According to a well-known anecdote, Bertrand Russell was once asked to prove that $2 + 2 = 5$ implies he was the Pope. Russell replied: subtract three from both sides and we get $1 = 2$; the Pope and I are two, so the Pope and I are one. That’s exactly why a contradiction in a theory is a disaster: if both $C$ and $\lnot C$ have been proved in it, every statement can be proved in it.
Swapping the hypothesis and the conclusion gives the converse $B \to A$. It may or may not be true: “if a number is divisible by $4$, it’s even” is true, but “if a number is even, it’s divisible by $4$” isn’t, with counterexample $6$. But every implication has a twin that’s always equivalent to it.
$A \to B \equiv \lnot B \to \lnot A$. The converse $B \to A$, on the other hand, is in general not equivalent to the original.
Four rows again. We look for where each implication is false: an implication has only one such row.
The meaning of the law is clear without a table too. “If it’s raining, the pavement is wet” and “if the pavement is dry, it isn’t raining” say the same thing. But “if the pavement is wet, it’s raining” is something else: a street-cleaning lorry may have watered it.
It seems impossible to go wrong here. In 1966 the English psychologist Peter Wason tested this with four cards. Play it yourself before reading on.
The rule “if one side has a vowel, the other side has an even number” is an implication $P \to Q$, and it can be broken only by a card where $P$ is true and $Q$ false. You have to turn over $E$ (in case there’s an odd number behind it) and $7$ (in case there’s a vowel behind it). On the card $K$ the hypothesis is false, on the card $4$ the conclusion is already true, and turning them over settles nothing. Most people choose $E$ and $4$, or just $E$; in various experiments something like one person in ten gives the right answer. We check the hypothesis but forget about the contrapositive, “if odd, then not a vowel”.
The bar rule “if someone is drinking beer, they’re over eighteen” works the same way: you have to check the beer and the sixteen-year-old. Here most people in the experiments answer correctly: we’re used to looking for rule-breakers in real life. The logic on the two tabs is the same, but the intuition differs, and mathematics needs a logic that doesn’t depend on what the subject is.
Implications in both directions give the equivalence $A \leftrightarrow B \equiv (A \to B) \land (B \to A)$: “$A$ if and only if $B$”, “$A$ is necessary and sufficient for $B$”. That’s how an islander is linked to their words: if $X$ is “$X$ is a knight” and $S$ is what was said, then $X \leftrightarrow S$. The whole island puzzle is a conjunction of such equivalences, and the widget above solved it with a table.
Lesson three: all and some
Connectives aren’t enough to write the most ordinary mathematical statement: “the square of any number is non-negative”. This isn’t about one statement but infinitely many: $0^2 \ge 0$, $1^2 \ge 0$, $(-2.5)^2 \ge 0$, …
A predicate is a statement with a variable, $P(x)$: it becomes a proposition when a particular value is substituted for $x$. Quantifiers turn a predicate into a statement about all values at once: $\forall x\ P(x)$ (“for every $x$, $P(x)$ holds”) and $\exists x\ P(x)$ (“there exists an $x$ for which $P(x)$ holds”). The quantifier usually says where $x$ is taken from: $\forall x \in \mathbb R\ \ x^2 \ge 0$.
The symbol $\exists$ is a turned letter E, for “exists”; it was introduced by Giuseppe Peano in 1897. The symbol $\forall$, an upside-down A (for “all”), appeared only in 1935, with Gerhard Gentzen. Quantifiers seem like simple words until there are two of them. Let $R(s, z)$ mean “student $s$ solved problem $z$”. The sentence $\forall z\ \exists s\ R(s, z)$ reads “every problem was solved by somebody”, and $\exists s\ \forall z\ R(s, z)$ reads “somebody solved every problem”. The only difference is the order of the symbols, but the meanings differ: in the second sentence one student covers everything, in the first each problem may have its own solver. The first follows from the second, but not the other way round.
Understanding of quantifiers is best tested by a game. A statement with quantifiers is a match between two players: the Prover moves for $\exists$ and picks a suitable object, the Refuter moves for $\forall$ and picks the most awkward one. The statement is true if the Prover has a winning strategy: that’s how truth is explained in game semantics, developed by the Finnish logician Jaakko Hintikka.
In the match for $\forall z\ \exists s$ the Prover picks a student already knowing the problem, and the choice may depend on the problem. In the match for $\exists s\ \forall z$ the choice is made blind: one student against any problem. It was the same in the game with the Sceptic in the chapter on limits: we named $N$ after hearing $\varepsilon$.
How do you negate statements with quantifiers? “Not all swans are white” means “there’s a swan that isn’t white”. For centuries Europeans thought swans were white, until at the end of the seventeenth century Dutch sailors saw black ones in Australia, and one black swan was enough.
The idea: the universal quantifier is a long “and”, the existential quantifier a long “or”, and everything reduces to De Morgan’s laws.
If $x$ runs over a finite set $\{x_1, \dots, x_n\}$, then $\forall x\ P(x)$ means exactly $P(x_1) \land P(x_2) \land \dots \land P(x_n)$, and $\exists x\ P(x)$ means $P(x_1) \lor \dots \lor P(x_n)$. By De Morgan’s law applied several times, the negation of a conjunction is the disjunction of the negations: $\lnot(P(x_1) \land \dots \land P(x_n)) \equiv \lnot P(x_1) \lor \dots \lor \lnot P(x_n)$, and that’s $\exists x\ \lnot P(x)$.
For an infinite set you can’t write out the long formula, but the argument is the same. The statement $\forall x\ P(x)$ is false exactly when $P(x)$ is true not for all $x$, that is, when it’s false for at least one $x$, and that means $\exists x\ \lnot P(x)$ is true. The second law follows from the first as De Morgan’s second law followed from the first: apply the first to the predicate $\lnot P$ and drop the double negation, $\lnot\,\forall x\ \lnot P(x) \equiv \exists x\ P(x)$, then negate both sides.
Hence a mechanical rule: to negate a chain of quantifiers, change each $\forall$ to $\exists$, each $\exists$ to $\forall$, and negate the statement at the end. One subtlety: a condition attached to a variable, as in $\forall \varepsilon > 0$, stays in place under negation. The notation $\forall \varepsilon > 0\ \ Q$ is short for $\forall \varepsilon\ (\varepsilon > 0 \to Q)$, and its negation, by the law for implications $\lnot(A \to B) \equiv A \land \lnot B$, is $\exists \varepsilon\ (\varepsilon > 0 \land \lnot Q)$, that is, $\exists \varepsilon > 0\ \ \lnot Q$.
Now we can say honestly what “the sequence doesn’t tend to $a$” means. The definition from chapter 25 and its negation:
$$a_n \to a:\quad \forall \varepsilon > 0\ \ \exists N\ \ \forall n > N\quad |a_n - a| < \varepsilon;$$ $$a_n \not\to a:\quad \exists \varepsilon > 0\ \ \forall N\ \ \exists n > N\quad |a_n - a| \ge \varepsilon.$$The second line is a ready-made strategy for the Sceptic: one tolerance $\varepsilon$, and after any index $N$ there’s a term outside the band. For $(-1)^n$ and $a = 1$, $\varepsilon = 1$ will do: after any $N$ there’s an odd $n$, and there $|a_n - 1| = 2 \ge 1$. In chapter 25 we found this move by guesswork; now the rule hands it to us.
A function $f$ is continuous at a point $a$ if $\forall \varepsilon > 0\ \exists \delta > 0\ \forall x$: $|x - a| < \delta$ implies $|f(x) - f(a)| < \varepsilon$. What does it mean for $f$ to be discontinuous at $a$?
Change $\forall \varepsilon$ to $\exists \varepsilon$, $\exists \delta$ to $\forall \delta$, $\forall x$ to $\exists x$, and negate the implication: $\lnot(A \to B) \equiv A \land \lnot B$. The result is the Sceptic’s strategy: name one tolerance, and in any window around $a$, however narrow, find a point where the value has jumped away from $f(a)$ by at least $\varepsilon$. That’s how the sign function $\operatorname{sgn} x$ behaves at zero: $\varepsilon = \frac12$ will do.
Lesson four: the grammar of proof
In chapter 0 a proof was called a chain of steps, each of which follows from the previous ones by the rules of logic. Now the rules can be named. Formally, a proof is a finite sequence of statements, each of which is an axiom, a theorem already proved, an assumption, or obtained from earlier ones by a rule of inference. The main rule of inference was known to the ancient Greek Stoics: from $A$ and $A \to B$ follows $B$. It’s called modus ponens, and its validity can be seen from a table: the formula $\bigl(A \land (A \to B)\bigr) \to B$ is a tautology. Such a sequence can be checked by a machine that doesn’t understand the meaning of the words; programs like Lean and Coq check proofs of big theorems exactly this way (chapter 60). People write more briefly, but the course of their proofs follows a few patterns, and each pattern is a tautology.
From the other side
Sometimes it’s hard to derive $B$ from $A$, but easy to derive $\lnot A$ from $\lnot B$. By the law of the contrapositive that’s the same thing.
If $a$ and $b$ are positive numbers and $ab > 100$, then $a > 10$ or $b > 10$.
It isn’t clear how to approach it directly. Let’s prove the contrapositive: if the conclusion is false, so is the hypothesis.
By contradiction
By contradiction: we assume $\lnot A$ and derive a contradiction $C \land \lnot C$; the formula $(\lnot A \to (C \land \lnot C)) \to A$ is a tautology. That’s how we proved the irrationality of $\sqrt2$ (chapter 6) and the infinitude of the primes (chapter 3). Here’s an even shorter example.
The number $\log_2 3$ is irrational.
The idea: a fraction would turn the logarithm into an equation between two whole numbers of different parity.
Suppose the contrary: $\log_2 3 = \frac pq$ with natural $p$ and $q$ (the logarithm is positive because $3 > 1$). By the definition of the logarithm (chapter 12) this means $2^{p/q} = 3$. Raise both sides to the power $q$: $2^p = 3^q$. On the left is a product of twos, an even number, since $p \ge 1$. On the right is a product of threes, which is odd. An even number doesn’t equal an odd one: a contradiction. So the assumption is false, and $\log_2 3$ isn’t a fraction.
Down the chain
Mathematical induction from chapter 13 is also a pattern: $\bigl(P(1) \land \forall k\ (P(k) \to P(k + 1))\bigr) \to \forall n\ P(n)$. Its rigour is best seen in a proof that only pretends to use it.
“Let’s prove that all horses are the same colour. The statement $P(n)$: in any herd of $n$ horses, all are the same colour. Base: $P(1)$ is true. Step: take a herd of $k + 1$ horses. Without the last horse there’s a herd of $k$, all the same colour; without the first, again $k$, again all the same colour. The horses in the middle belong to both herds, so they’re all the same colour.” Where’s the mistake?
In a herd of two horses there are no “horses in the middle”: without the last one the first remains, without the first the last remains, and the two herds have no horses in common. The step has to work for every $k$, and at $k = 1$ it breaks, so the chain of dominoes snaps at the second. The example is attributed to George Pólya.
Show one, or prove there is one
A statement “there exists an $x$ with property $P$” is most easily proved by construction, by exhibiting such an $x$. But sometimes existence can be proved without showing the object.
There exist irrational numbers $a$ and $b$ for which $a^b$ is rational.
The idea: consider two cases, in one of which the answer is ready, while in the other it’s obtained from the first.
Consider the number $\sqrt2^{\sqrt2}$. It’s either rational or not: the law of the excluded middle. If it’s rational, $a = b = \sqrt2$ will do; both are irrational (chapter 6). If it’s irrational, take $a = \sqrt2^{\sqrt2}$ and $b = \sqrt2$. Then by the rule $(x^u)^v = x^{uv}$ for positive $x$ we get $a^b = \sqrt2^{\sqrt2 \cdot \sqrt2} = \sqrt2^{\,2} = 2$, a rational number. In both cases the pair we need has been found.
The proof is flawless, but it doesn’t say which of the two pairs works. Such proofs are called non-constructive; the intuitionists, a group of twentieth-century logicians, didn’t accept them. Here, as it happens, the answer is known: by the Gelfond–Schneider theorem (1934) the number $\sqrt2^{\sqrt2}$ is transcendental, so the second case is the one that works. And there’s a very simple constructive example: $\sqrt2^{\log_2 9} = 2^{\frac12\log_2 9} = 2^{\log_2 3} = 3$, where $\log_2 9$ is irrational for the same reason as $\log_2 3$.
With a single example
The last pattern is refutation. Since $\lnot\,\forall x\ P(x) \equiv \exists x\ \lnot P(x)$, a “for all” statement is refuted by a single counterexample. But a “there exists” statement can’t be refuted by an example: its negation begins with “for all” and needs a proof. The course began with this asymmetry.
Lesson five: sets
So far we’ve learned verbs and conjunctions. Time for nouns: a mathematician almost always talks about many objects at once, “all the roots of an equation”, “the points of a circle”, “the even numbers”.
By a set we mean any collection into a whole of definite, well-distinguished objects of our perception or of our thought, which are called the elements of the set.
A set in mathematics is a primitive notion: it isn’t defined in terms of others but described by rules for handling it. The main rule: a set is completely determined by its elements. The notation $x \in A$ is read “$x$ belongs to $A$”, and $x \notin A$ “doesn’t belong”. Sets $A$ and $B$ are equal if they have the same elements. $A$ is a subset of $B$, written $A \subset B$, if every element of $A$ belongs to $B$; some textbooks write $A \subseteq B$, keeping $\subset$ for a subset that isn’t the whole of $B$. The set with no elements is called empty and written $\varnothing$.
A set is given either by a list, $\{2, 3, 5, 7\}$, or by a property: $\{x \in \mathbb R \mid x^2 < 2\}$ is all real $x$ with $x^2 < 2$, that is, the interval $(-\sqrt2, \sqrt2)$. Order and repetition in a list don’t matter: $\{1, 2, 2\} = \{2, 1\}$, they have the same elements.
The empty set is a subset of every $A$: the condition $\forall x\ (x \in \varnothing \to x \in A)$ holds, because the hypothesis $x \in \varnothing$ is always false, and anything follows from a falsehood. And there’s only one empty set: two empty sets have the same elements, namely none.
New sets are made from sets $A$ and $B$. The union $A \cup B$ is the elements that lie in $A$ or in $B$. The intersection $A \cap B$ is the elements that lie in both $A$ and $B$. The difference $A \setminus B$ is the elements of $A$ not lying in $B$. If all the sets under consideration lie inside one enclosing set $U$, then the complement $A^{c} = U \setminus A$ is the elements of $U$ not lying in $A$.
Operations on sets are the connectives of logic in new clothes: $x \in A \cup B$ means $x \in A \lor x \in B$, intersection is “and”, complement is “not”. Every law of logic immediately gives a law for sets, and Euler circles are a truth table drawn in the plane.
$(A \cup B)^{c} = A^{c} \cap B^{c}$ and $(A \cap B)^{c} = A^{c} \cup B^{c}$.
Let’s draw both sides of the first law and check that the same thing is shaded. Each of the four regions of the picture is a row of the table from lesson one.
How many rows of the truth table of the formula $A \lor B \lor C \lor D$ contain T? In other words, how many of the sixteen regions does the union of four sets in general position cover?
There are $2^4 = 16$ rows in all. The disjunction is false only where all four variables are false: one row. The other $16 - 1 = 15$ rows give T.
Lesson six: a function is a set of pairs
In chapter 9 a function was a rule: each $x$ is assigned exactly one $y$. But what is a “rule”? Set theory gives an unexpected answer: a function can be identified with its graph.
The Cartesian product $A \times B$ is the set of all ordered pairs $(a, b)$ with $a \in A$ and $b \in B$; the coordinate plane is $\mathbb R \times \mathbb R$. A map $f\colon A \to B$ is a subset $f \subset A \times B$ that contains, for each $a \in A$, exactly one pair $(a, b)$. This unique $b$ is written $f(a)$. The word “function” is usually kept for maps whose values are numbers.
There’s no “rule” in the definition: a map is a list of pairs in which each element of $A$ appears first exactly once, and it needn’t be given by a formula. The three main properties of maps are about the arrows leading from $A$ to $B$.
A map $f\colon A \to B$ is called an injection if it sends different elements to different ones: $a \ne a'$ implies $f(a) \ne f(a')$. A surjection, if at least one arrow leads into every $b \in B$: $\forall b \in B\ \exists a \in A\ \ f(a) = b$. A bijection, or one-to-one correspondence, if it’s both: exactly one arrow leads into each element of $B$.
You won’t manage to build an injection from five dots into four: that’s the pigeonhole principle, five pigeons in four holes. A bijection exists only between sets of the same size, and only a bijection can be run backwards.
A map $f\colon A \to B$ has an inverse $g\colon B \to A$, that is, $g(f(a)) = a$ for all $a \in A$ and $f(g(b)) = b$ for all $b \in B$, if and only if $f$ is a bijection.
The idea: the inverse map is the same pairs read from right to left, and they form a map exactly when one arrow leads into each point of $B$.
Suppose the inverse $g$ exists. If $f(a) = f(a')$, apply $g$ to both sides: $a = g(f(a)) = g(f(a')) = a'$, so $f$ is an injection. For any $b \in B$ the element $a = g(b)$ goes to $f(g(b)) = b$, so $f$ is a surjection. Conversely, let $f$ be a bijection. Flip each pair $(a, b)$ in $f$ to get a set of pairs $g \subset B \times A$. For each $b$ there’s at least one pair $(b, a)$ in $g$, because $f$ is surjective, and at most one, because $f$ is injective. So $g$ is a map, and by construction $g(f(a)) = a$ and $f(g(b)) = b$.
If $A$ and $B$ are finite with the same number of elements, a map $f\colon A \to B$ is injective if and only if it’s surjective.
The idea: count how many points of $B$ are hit by arrows.
Let $A$ and $B$ have $n$ elements each. The image $f(A) = \{f(a) \mid a \in A\}$ is a subset of $B$. If $f$ is injective, the $n$ different elements of $A$ have different images, and $f(A)$ has exactly $n$ elements. A subset of $n$ elements of a set of $n$ elements is the whole set, so $f(A) = B$ and $f$ is surjective. If $f$ isn’t injective, two elements of $A$ landed on one point, and there are fewer than $n$ images: $f(A) \ne B$, and $f$ isn’t surjective. By the law of the contrapositive, that’s the second half of the statement.
For infinite sets this is false, and that’s where the next chapter begins. The map $n \mapsto n + 1$ from $\mathbb N$ to $\mathbb N$ is injective, but no arrow leads into one. And $n \mapsto \lceil n/2 \rceil$ (half, rounded up) hits every natural number, but one is hit twice, from $1$ and from $2$.
How many surjections are there from the set $\{1, 2, 3\}$ onto the set $\{a, b\}$?
There are $2^3 = 8$ maps in all: each of the three elements independently chooses $a$ or $b$ (the rule of product). Only two of them aren’t surjective: all to $a$ and all to $b$. That leaves $8 - 2 = 6$. None of them is an injection: three elements can’t have two different images.
Lesson seven: equal in different ways
The fractions $\frac12$, $\frac24$ and $\frac36$ are written differently, but they’re one number (chapter 5). A clock shows the same thing at 3 in the morning and at 15:00. The device is the same: objects are declared “the same” if they agree in something important, and you work with whole groups.
A relation on a set $A$ is a subset $R \subset A \times A$; instead of $(a, b) \in R$ one writes $a \sim b$. A relation is called an equivalence relation if it’s reflexive ($a \sim a$ for all $a$), symmetric ($a \sim b$ implies $b \sim a$) and transitive ($a \sim b$ and $b \sim c$ imply $a \sim c$). The equivalence class of an element $a$ is the set $[a] = \{x \in A \mid x \sim a\}$ of all elements equivalent to it.
“Having the same remainder on division by $12$” is an equivalence relation on the integers. “Divides” isn’t: $2$ divides $4$, but $4$ doesn’t divide $2$, so there’s no symmetry. “Differing by less than one” isn’t either: $0 \sim 0.6$ and $0.6 \sim 1.2$, but $0$ and $1.2$ differ by more than one, so transitivity fails. An equivalence, on the other hand, cuts a set into pieces with nothing left over and no overlaps.
The classes of an equivalence relation on a set $A$ cover all of $A$, and any two classes either coincide or don’t intersect.
The idea: if two classes have an element in common, transitivity builds a bridge through it from any element of one class to any element of the other.
Each element $a$ lies in its own class $[a]$, because $a \sim a$ (reflexivity), so the classes cover $A$. Suppose the classes $[a]$ and $[b]$ have a common element $c$: $c \sim a$ and $c \sim b$. Take any $x \in [a]$, that is, $x \sim a$. By symmetry $a \sim c$, by transitivity $x \sim c$, and with $c \sim b$, by transitivity again, $x \sim b$, that is, $x \in [b]$. So $[a] \subset [b]$. Swapping the roles of $a$ and $b$, we get $[b] \subset [a]$, and the classes coincide.
Now we can say what a remainder is and what a fraction is without the words “the same thing written differently”. The classes of integers modulo $n$ are the elements of $\mathbb Z_n$ from the chapter on remainders: $\mathbb Z_{12}$ is twelve classes, the numbers on a clock face. And a positive rational number is a class of pairs of natural numbers under the relation $(p, q) \sim (p', q') \iff pq' = p'q$: the pairs $(1, 2)$, $(2, 4)$, $(3, 6)$, … form one class, and that class is $\frac12$. On the grid of points in the plane each class lies on a ray from the origin: a picture we’ll need in the next chapter.
How many different equivalence relations are there on the set $\{a, b, c\}$?
By the theorem on splitting, an equivalence relation is the same as a partition of the set into classes: knowing the classes, we know who is equivalent to whom, and vice versa. A three-element set has five partitions: everyone in one class; each in their own; and three ways to single out a pair, $\{a, b\}\{c\}$, $\{a, c\}\{b\}$, $\{b, c\}\{a\}$. Answer: $5$.
Lesson eight: the word that breaks the dictionary
Cantor allowed “any collection” of objects to be called a set. Let’s take this seriously. The set of all sets, if it exists, is itself a set and so lies in itself. The set of all teacups isn’t a teacup and doesn’t lie in itself. Let’s gather together all the sets that don’t lie in themselves:
$$R = \{x \mid x \notin x\}.$$The set $R$ of all sets that don’t contain themselves as an element doesn’t exist.
This is the conversation with the islander who said “I am a knave”. Let’s ask about $R$ itself: does it lie in itself?
Bertrand Russell found this contradiction in 1901; Ernst Zermelo in Göttingen had stumbled on it a little earlier but didn’t publish. In June 1902 Russell wrote about it to Gottlob Frege, who was finishing the second volume of his Basic Laws of Arithmetic, an attempt to derive the whole of arithmetic from logic. Frege’s axioms allowed everything with some property to be gathered into a set, and in his system the set $R$ existed. The volume came out in 1903 with an afterword:
Hardly anything more unfortunate can befall a scientific writer than to have one of the foundations of his edifice shaken after the work is finished.
In the popular version, which Russell himself retold, the paradox goes like this: the village barber shaves those and only those villagers who don’t shave themselves. Does he shave himself? Both answers are impossible, but the conclusion is simple: there’s no such barber. With sets the conclusion is the same, and the crisis is that the old rules allowed such a set to be built.
The way out was found by the same Zermelo. In 1908 he proposed axioms under which a set can’t be gathered “from everything in the world” but can only be cut out of one that already exists.
For any set $A$ and any property $P$ there exists the set $\{x \in A \mid P(x)\}$ of all elements of $A$ that have the property $P$.
There’s no set $V$ whose elements are all sets.
The idea: if $V$ existed, the axiom of separation would cut Russell’s set out of it.
Suppose $V$ exists. By the axiom of separation with the property $P(x)$: “$x \notin x$”, there’s a set $R = \{x \in V \mid x \notin x\}$. All sets lie in $V$, so $R$ consists of exactly all the sets that don’t contain themselves. By the theorem on Russell’s paradox there’s no such set. A contradiction, and $V$ doesn’t exist.
The axiom of separation makes its move against the paradox modestly: the contradictory set isn’t forbidden, there’s simply nothing to build it from. Today the foundation of mathematics is the ZFC system: Zermelo’s axioms, supplemented in 1922 by Abraham Fraenkel and Thoralf Skolem. The letter C in the name is a reminder that among them is the axiom of choice, which is often considered separately from the rest. Here are all nine axioms in outline, in words:
| Axiom | What it allows or asserts |
|---|---|
| extensionality | sets with the same elements are equal |
| pairing | from $a$ and $b$ one can form the set $\{a, b\}$ |
| union | the elements of the elements of a set can be poured into one set |
| power set | all the subsets of a set $A$ form a set |
| separation | the elements with a given property can be cut out of a set |
| replacement | the image of a set under a map given by a formula is also a set |
| infinity | there’s an infinite set in which all the natural numbers fit |
| regularity | a chain $\dots \in x_3 \in x_2 \in x_1$ can’t descend for ever; in particular, $x \notin x$ |
| choice | from each set of a family of non-empty sets one element can be chosen |
Remarkably, almost all of mathematics needs nothing more. Numbers too are built from sets: in 1923 John von Neumann proposed taking the empty set as zero, $\{\varnothing\}$ as one, $\{\varnothing, \{\varnothing\}\}$ as two, and in general $n + 1 = n \cup \{n\}$. Here it’s convenient to start the natural numbers at zero; in many school textbooks zero isn’t counted as a natural number, and that’s a matter of convention, not truth. The principle of induction, which Peano declared an axiom of arithmetic in 1889, becomes a theorem in ZFC. From pairs of natural numbers the integers and fractions are built (lesson seven), from fractions the real numbers, and from them functions, spaces, probabilities. This whole course grows out of the nine rows of the table.
An exam on the island
A grammar is learned not only by reading but by exercises. The trainer has three levels: count the rows of a truth table, choose the correct negation of a statement with quantifiers, and sort out the island’s inhabitants.
Where next
For finite sets we proved: if $A$ and $B$ have the same number of elements, an injection from $A$ to $B$ is necessarily a bijection. For the natural numbers this is false: the shift $n \mapsto n + 1$ maps $\mathbb N$ one-to-one onto its own part $\{2, 3, 4, \dots\}$. So an infinite set has as many elements as a part of itself? Galileo noticed this back in 1638 (there are as many squares $1, 4, 9, 16, \dots$ as there are natural numbers) and decided that the words “more” and “fewer” don’t apply to infinities. Georg Cantor decided otherwise: to call sets the same size if there’s a bijection between them, and see what happens. What happened is that infinities come in different sizes. Can the natural numbers be compared with the points of a segment, and is there a largest infinity? Three people argue about it in the next chapter.