Raw

Lecture 1. Set theory

Overview

Set theory is the foundational language of discrete mathematics. Almost every object we study later in this course — relations, functions, Boolean algebras, graphs, probability spaces, and the state sets of automata — is built on top of sets. When we say “a graph is a pair (V,E)(V, E) where EE is a set of pairs of vertices,” or “a relation from AA to BB is a subset of A×BA \times B,” or “an event is a subset of the sample space,” we are speaking set theory. Learning to read and write in this language fluently now pays dividends in every subsequent lecture.

This chapter introduces the primitive notion of a set and the membership relation, catalogues the special and numeric sets we will reuse constantly, and develops the vocabulary for comparing sets (subset, equality), describing them (roster, set-builder, recursive), and measuring them (cardinality, power set, countability). Along the way we prove the standard structural facts — A\varnothing \subseteq A, the double-inclusion criterion for equality, P(A)=2n|\mathcal{P}(A)| = 2^{n} — rigorously rather than merely asserting them, because a large part of the value of a discrete-mathematics course is learning how to prove statements about discrete structures. We close with ordered pairs, tuples, and the Cartesian product, which lead directly into relations, and with a cautionary historical note on Russell’s paradox and applications to computer science.

Set operations (union, intersection, difference, complement), Venn diagrams, and the algebraic identities that govern them are the subject of Lecture 2; here we build the ground they stand on. Relations, which are defined as subsets of Cartesian products, follow in Lecture 3.

A note on rigor. Several results below are stated as theorems or propositions and come with a proof, delimited by Proof. … ∎. Read the proofs actively: at each step ask “why is this step allowed?” The proof techniques on display here — direct proof, proof by contradiction, proof by cases, proof by induction, and proof by exhibiting a bijection — are exactly the techniques you will reuse throughout the course.


1.1 Sets and membership

1.1 Motivation

Collections are everywhere. The students enrolled in a course, the files in a directory, the primes below 100100, the reachable states of a program, the pixels of an image, the rows of a database table — each is a collection of objects regarded as a single entity. Mathematics needs one clean, uniform notion that captures “a collection considered as a whole” while ignoring incidental details such as the order in which we happen to list the objects or how many times we mention each one. That notion is the set.

1.2 The primitive notions

We take two notions as primitive (undefined, understood intuitively): set and membership.

Definition (set). A set is an unordered collection of distinct objects considered as a whole. The objects are called the elements (or members) of the set. A set is completely determined by which objects it contains — not by any order among them, and not by any repetition.

Definition (membership). We write xAx \in A to mean “xx is an element of AA” (read “xx belongs to AA”), and xAx \notin A to mean “xx is not an element of AA.” For every object xx and set AA, exactly one of xAx \in A, xAx \notin A holds.

Sets are conventionally named with capital letters (A,B,C,A, B, C, \dots) and their elements with lowercase letters, though this is only a convention: an element of a set may itself be a set (indeed, in the standard axiomatic development every element is a set).

Two structural principles follow immediately from “a set is determined by its members”:

  • Order is irrelevant: {1,2,3}={3,1,2}\{1,2,3\} = \{3,1,2\}.
  • Repetition is irrelevant: {1,2,2,3}={1,2,3}\{1,2,2,3\} = \{1,2,3\}.

An element either is or is not in a set; there is no notion of “how many times” or “in what position.” (Structures that do track multiplicity are called multisets, and structures that track order are sequences or tuples; both are built on top of sets and appear later.)

Example 1.1. Let A={a,e,i,o,u}A = \{a, e, i, o, u\} be the set of vowels of the English alphabet. Then eAe \in A, but bAb \notin A. The set AA has exactly five members, and {u,a,o,i,e}\{u, a, o, i, e\} denotes the very same set.

Example 1.2. {x}\{x\}, a set with exactly one element xx, is called a singleton. Thus {7}\{7\}, {a}\{a\}, and {}\{\varnothing\} are singletons. Note carefully that 77 and {7}\{7\} are different objects: the first is a number, the second is a set whose one element is that number.

Example 1.3 (sets of sets). Elements may themselves be sets. In B={1, {1}, {1,2}}B = \{\, 1,\ \{1\},\ \{1,2\} \,\} we have 1B1 \in B and {1}B\{1\} \in B, and these are three distinct elements, so B=3|B| = 3. But 2B2 \notin B: although 22 appears inside the element {1,2}\{1,2\}, it is not itself an element of BB. Membership does not “see through” the braces.

Remark (well-definedness). For a description to name a set, membership must be definite: given any object, it must be determinate whether it belongs. “The set of large numbers” is not well-defined (how large is large?), whereas “the set of integers greater than 10610^{6}” is. Vagueness, not infinitude, is the problem; infinite sets like N\mathbb{N} are perfectly well-defined.

Common pitfall (element vs. set). Beginners routinely confuse an object xx with the singleton {x}\{x\}, and confuse membership \in with the subset relation \subseteq (§1.4). Keep them apart: xAx \in A relates an object to a set; {x}A\{x\} \subseteq A relates a set to a set. Both can be true at once, and they say the same thing herexA    {x}Ax \in A \iff \{x\}\subseteq A — but they are grammatically different statements, and the confusion becomes a real error once the elements are themselves sets (Example 1.3).


1.2 Special sets: the empty set and the universe

Two sets play a distinguished structural role and deserve names.

Definition (empty set). The empty set (or null set), written \varnothing (also {}\{\,\}), is the unique set that has no elements at all. For every object xx we have xx \notin \varnothing.

The empty set is the additive “zero” of set theory: small, but indispensable. It is the base case of countless recursive definitions and the value returned when a search finds nothing.

Beware the following distinction, which trips up almost everyone once:

{}.\varnothing \ne \{\varnothing\}.

The left-hand side contains nothing (=0|\varnothing| = 0). The right-hand side is a singleton whose one element happens to be the empty set ({}=1|\{\varnothing\}| = 1). By analogy: an empty box and a box that contains one empty box are not the same box. We will prove below (Proposition 1.5) that there is genuinely only one empty set.

Definition (universal set). In any particular discussion we fix a universal set (or universe), often written UU, consisting of all objects relevant to that discussion. Every set under consideration is understood to be a subset of UU.

The universe is a matter of context, chosen for convenience: when discussing integers, U=ZU = \mathbb{Z}; when discussing letters, UU is the alphabet; in a dice problem, U={1,2,3,4,5,6}U = \{1,2,3,4,5,6\}. The universe becomes essential in Lecture 2, where the complement A\overline{A} of a set is defined as UAU \setminus A and therefore depends on which UU we chose.

Common pitfall (no “set of everything”). It is tempting to take UU to be “the set of absolutely all objects.” §1.12 (Russell’s paradox) shows that an unrestricted universal set leads to contradiction. In practice UU is always some concrete, safely-sized set fixed by the problem, never “everything.”

Example 1.4. If the universe is U={1,2,3,4,5,6}U = \{1,2,3,4,5,6\} (one throw of a die), then in probabilistic language the “impossible outcome” corresponds to \varnothing and the “certain outcome” corresponds to UU itself. There is exactly one empty set, whatever the context.

Proposition 1.5 (uniqueness of the empty set). There is exactly one set with no elements.

Proof. Suppose E1E_1 and E2E_2 are both sets with no elements. We show E1=E2E_1 = E_2 using the equality criterion of §1.5 (double inclusion). To show E1E2E_1 \subseteq E_2 we must verify xE1    xE2x \in E_1 \implies x \in E_2 for every xx; but xE1x \in E_1 is false for every xx (as E1E_1 has no elements), so the implication holds vacuously (§1.4.2). Hence E1E2E_1 \subseteq E_2. By the identical argument with the roles swapped, E2E1E_2 \subseteq E_1. By double inclusion, E1=E2E_1 = E_2. Since any two empty sets coincide, the empty set is unique. ∎

Because it is unique, we are entitled to speak of the empty set and to give it its own symbol \varnothing.


1.3 Numeric sets

Certain infinite sets of numbers recur so often that they have reserved blackboard-bold symbols. Memorize this hierarchy; we will use it in every lecture.

Symbol Name Description / typical elements
N\mathbb{N} Natural numbers {1,2,3,4,}\{1, 2, 3, 4, \dots\} — the counting numbers
Z\mathbb{Z} Integers {,3,2,1,0,1,2,3,}\{\dots, -3, -2, -1, 0, 1, 2, 3, \dots\}
Q\mathbb{Q} Rational numbers fractions pq\tfrac{p}{q} with p,qZp,q \in \mathbb{Z}, q0q \ne 0, e.g. 42,12,410\tfrac{4}{2}, \tfrac{1}{2}, \tfrac{4}{10}
Irrational numbers reals that are not rational, e.g. 2,π,e\sqrt{2}, \pi, e
R\mathbb{R} Real numbers all rationals and all irrationals together
II Imaginary numbers {bibR}\{\,bi \mid b \in \mathbb{R}\,\} where i2=1i^2 = -1
C\mathbb{C} Complex numbers {a+bia,bR}\{\,a + bi \mid a, b \in \mathbb{R}\,\}

A few clarifications:

  • Following the course deck, we take N={1,2,3,}\mathbb{N} = \{1, 2, 3, \dots\} (starting at 11). Many authors (and most computer scientists) include 00 and write N={0,1,2,}\mathbb{N} = \{0,1,2,\dots\} or N0\mathbb{N}_0. Neither convention is more correct; watch for which one each text uses, because it changes statements like “0N0 \in \mathbb{N}.”
  • Rational numbers are exactly those expressible as a ratio of two integers. A rational has a decimal expansion that either terminates (12=0.5\tfrac{1}{2} = 0.5) or is eventually periodic (13=0.3\tfrac{1}{3} = 0.\overline{3}, 17=0.142857\tfrac{1}{7} = 0.\overline{142857}).
  • Irrational numbers have non-terminating, non-repeating decimal expansions; 2=1.41421\sqrt{2} = 1.41421\dots and π=3.14159\pi = 3.14159\dots cannot be written as a ratio of integers (Theorem 1.7 proves this for 2\sqrt 2).
  • The imaginary unit ii satisfies i2=1i^2 = -1, and a complex number combines a real part aa and an imaginary part bb as a+bia + bi.

These sets nest inside one another:

NZQRC.\mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C}.

Every natural number is an integer, every integer is rational (e.g. 3=31-3 = \tfrac{-3}{1}), every rational is real, and every real is complex (with imaginary part 00). Each inclusion is proper — there are integers that are not natural (1-1), rationals that are not integers (12\tfrac12), reals that are not rational (2\sqrt2), and complexes that are not real (ii).

The numeric sets nested inside one another: ℕ ⊂ ℤ ⊂ ℚ ⊂ ℝ ⊂ ℂ

Example 1.6 (classification). Classify 7, 34, 2, 5, 2i-7,\ \tfrac{3}{4},\ \sqrt{2},\ 5,\ 2i.

  • 5N5 \in \mathbb{N} (and hence also in Z,Q,R,C\mathbb{Z}, \mathbb{Q}, \mathbb{R}, \mathbb{C}).
  • 7Z-7 \in \mathbb{Z} but 7N-7 \notin \mathbb{N}.
  • 34Q\tfrac{3}{4} \in \mathbb{Q} but 34Z\tfrac{3}{4} \notin \mathbb{Z}.
  • 2R\sqrt{2} \in \mathbb{R} (irrational) but 2Q\sqrt{2} \notin \mathbb{Q}.
  • 2iC2i \in \mathbb{C} (in fact 2iI2i \in I) but 2iR2i \notin \mathbb{R}.

The blackboard-bold letters denote the smallest customary system; each number also lives in every larger system in the chain.

Intervals of R\mathbb{R}

Subsets of the real line are named by interval notation. For a<ba<b: the closed interval [a,b]={x:axb}[a,b]=\{x:a\le x\le b\} includes both endpoints; the open interval (a,b)={x:a<x<b}(a,b)=\{x:a<x<b\} excludes both; the half-open [a,b)[a,b) and (a,b](a,b] include exactly one; and the rays [a,)={x:xa}[a,\infty)=\{x:x\ge a\}, (,b)={x:x<b}(-\infty,b)=\{x:x<b\} (and their variants) are unbounded. A square bracket means the endpoint is in the set, a round bracket that it is not; ±\pm\infty always takes a round bracket. This notation is used throughout the course — e.g. (0,1)(0,1) for a probability, [a,b][a,b] for a function’s domain.

3.1 A worked proof: 2\sqrt 2 is irrational

That the chain QR\mathbb{Q} \subset \mathbb{R} is proper is not obvious — one must produce a real number and prove it is not a ratio of integers. The classic example is 2\sqrt 2. The proof, known to the Pythagoreans around 500 BCE, is a model of the technique proof by contradiction.

Theorem 1.7. 2\sqrt{2} is irrational; that is, there are no integers p,qp, q with q0q \ne 0 and (pq)2=2\left(\tfrac{p}{q}\right)^2 = 2.

Proof. Suppose, for contradiction, that 2\sqrt 2 is rational. Then we may write 2=pq\sqrt 2 = \tfrac{p}{q} with p,qZp, q \in \mathbb{Z}, q0q \ne 0, and the fraction in lowest terms, i.e. gcd(p,q)=1\gcd(p,q) = 1 (any fraction can be reduced to lowest terms by cancelling common factors). Squaring gives 2=p2q22 = \dfrac{p^2}{q^2}, hence

p2=2q2.()p^2 = 2q^2. \tag{$\ast$}

Equation ()(\ast) says p2p^2 is even. Now p2p^2 even forces pp even: for if pp were odd, say p=2m+1p = 2m+1, then p2=4m2+4m+1=2(2m2+2m)+1p^2 = 4m^2 + 4m + 1 = 2(2m^2+2m)+1 would be odd. So pp is even; write p=2kp = 2k. Substituting into ()(\ast):

(2k)2=2q2    4k2=2q2    q2=2k2.(2k)^2 = 2q^2 \;\Longrightarrow\; 4k^2 = 2q^2 \;\Longrightarrow\; q^2 = 2k^2.

By the same reasoning q2q^2 is even, so qq is even. But now 2p2 \mid p and 2q2 \mid q, contradicting gcd(p,q)=1\gcd(p,q) = 1. The assumption that 2\sqrt 2 is rational is therefore untenable, and 2\sqrt 2 is irrational. ∎

Remark. The same argument shows n\sqrt{n} is irrational whenever nn is a natural number that is not a perfect square. The proofs that π\pi and ee are irrational are far harder and belong to analysis; we cite them but do not prove them here.

Historical note. The discovery that the diagonal of a unit square (length 2\sqrt 2) is incommensurable with its side shattered the Pythagorean belief that all magnitudes are ratios of whole numbers. It is one of the earliest known proofs by contradiction and one of the first genuine theorems about the structure of the number line.


1.4 Subsets and inclusion

4.1 The definition

Definition (subset). AA is a subset of BB, written ABA \subseteq B, when every element of AA is also an element of BB:

AB        (x)(xA    xB).A \subseteq B \;\iff\; (\forall x)\,(x \in A \implies x \in B).

If in addition ABA \ne B — i.e. BB has at least one element not in AA — we call AA a proper subset of BB and write ABA \subset B (some texts write ABA \subsetneq B to stress properness).

Intuitively ABA \subseteq B says “AA fits inside BB.” The definition is a universally quantified conditional, and that logical shape dictates how we prove inclusions: to prove ABA \subseteq B, take an arbitrary xAx \in A and derive xBx \in B. This “take an arbitrary element” move is the single most common opening line in set-theoretic proofs.

Venn diagram of A ⊆ B: circle A sits entirely inside circle B

Example 1.8. Let A={1,2}A = \{1, 2\} and B={1,2,3,4}B = \{1, 2, 3, 4\}. Every element of AA (11 and 22) lies in BB, so ABA \subseteq B; and since 3B3 \in B but 3A3 \notin A, the inclusion is proper: ABA \subset B. By contrast, {1,5}⊈B\{1, 5\} \not\subseteq B because 5B5 \notin B — a single “witness” element outside BB suffices to refute an inclusion.

Common pitfall (\in vs. \subseteq). These are different relations. With A={1,2}A = \{1, 2\}: 1A1 \in A (true), {1}A\{1\} \subseteq A (true), but 1A1 \subseteq A is a type error (11 is not a set) and {1}A\{1\} \in A is false (AA’s elements are 11 and 22, not the set {1}\{1\}). The traps get sharper with nested sets: for A={1,{2}}A = \{1, \{2\}\} we have {2}A\{2\} \in A and {{2}}A\{\{2\}\} \subseteq A, but 2A2 \notin A and {2}⊈A\{2\} \not\subseteq A.

4.2 The empty set is a subset of everything (vacuous truth)

Our first structural theorem is one students often find surprising, because it seems to say “nothing is inside everything.” The resolution is the logical principle of vacuous truth: a conditional P    QP \implies Q whose hypothesis PP is false is counted as true, regardless of QQ. (Compare an unfulfillable promise: “if you finish a marathon in 11 hour, I’ll pay you 1000 dollars” is never broken if no such marathon is ever run.) Vacuous truth is developed fully in the propositional-logic material; here we use it.

Proposition 1.9. For every set AA,   A\;\varnothing \subseteq A.

Proof. By definition we must show (x)(x    xA)(\forall x)\,(x \in \varnothing \implies x \in A). Let xx be arbitrary. The hypothesis “xx \in \varnothing” is false, because the empty set has no elements. A conditional with a false hypothesis is true (vacuous truth). Hence x    xAx \in \varnothing \implies x \in A holds for this — and therefore every — xx. Thus A\varnothing \subseteq A. ∎

Alternative proof (by contradiction). Suppose ⊈A\varnothing \not\subseteq A. By the definition of \subseteq, this failure means there exists an element xx with xx \in \varnothing and xAx \notin A. But xx \in \varnothing is impossible. This contradiction shows A\varnothing \subseteq A. ∎

The second proof is worth studying: it shows how to negate a subset claim. The negation of “x(xAxB)\forall x\,(x\in A \Rightarrow x \in B)” is “x(xAxB)\exists x\,(x \in A \wedge x \notin B).” To disprove ABA\subseteq B you exhibit one such witness xx; to prove it you rule all witnesses out.

4.3 Reflexivity and transitivity of \subseteq

Proposition 1.10 (reflexivity). For every set AA,   AA\;A \subseteq A.

Proof. For every xx, the conditional xA    xAx \in A \implies x \in A is true (a statement implies itself). Hence AAA \subseteq A. ∎

Proposition 1.11 (transitivity). If ABA \subseteq B and BCB \subseteq C, then ACA \subseteq C.

Proof. Let xx be an arbitrary element of AA. Since ABA \subseteq B, from xAx \in A we get xBx \in B. Since BCB \subseteq C, from xBx \in B we get xCx \in C. Thus every element of AA is an element of CC, i.e. ACA \subseteq C. ∎

Remark (a preview of order theory). Propositions 1.10, 1.11 and Theorem 1.13 (antisymmetry) together say that \subseteq is a partial order on any collection of sets: reflexive, antisymmetric, and transitive. Partial orders are studied systematically in the lecture on relations (Lecture 3); the power set P(A)\mathcal{P}(A) ordered by \subseteq is the prototypical example and reappears in the lecture on Boolean algebras and lattices.

Example 1.12. {1}{1,2}{1,2,3}\{1\} \subseteq \{1,2\} \subseteq \{1,2,3\}, so by transitivity {1}{1,2,3}\{1\}\subseteq\{1,2,3\} — as is directly visible. Transitivity earns its keep in proofs where the intermediate set BB is not something you would want to compute element-by-element.


1.5 Set equality and the double-inclusion method

5.1 Extensionality

When are two sets equal? The guiding principle, called the axiom of extensionality, is that a set is nothing more than its members:

Definition / Axiom (extensionality). Two sets are equal, A=BA = B, exactly when they have the same elements:

A=B        (x)(xA    xB).A = B \;\iff\; (\forall x)\,(x \in A \iff x \in B).

Extensionality is why order and repetition inside braces do not matter (§1.1): {1,2,2,3}\{1,2,2,3\} and {3,1,2}\{3,1,2\} have the same members, hence are equal. It also means sets described in totally different ways can turn out equal — and proving such equalities is a core skill.

5.2 The double-inclusion criterion

The biconditional “xA    xBx \in A \iff x \in B” splits into two conditionals, and those two conditionals are precisely two subset statements. This yields the workhorse theorem of the whole chapter.

Theorem 1.13 (equality via double inclusion; antisymmetry of \subseteq). For all sets A,BA, B,

A=B        (AB and BA).A = B \;\iff\; \big(A \subseteq B \ \text{and}\ B \subseteq A\big).

Proof. (\Rightarrow) Suppose A=BA = B. By extensionality, for every xx we have xA    xBx \in A \iff x \in B. In particular xA    xBx \in A \implies x \in B (so ABA \subseteq B) and xB    xAx \in B \implies x \in A (so BAB \subseteq A).

(\Leftarrow) Suppose ABA \subseteq B and BAB \subseteq A. Let xx be arbitrary. From ABA \subseteq B we have xA    xBx \in A \implies x \in B; from BAB \subseteq A we have xB    xAx \in B \implies x \in A. Combining the two conditionals, xA    xBx \in A \iff x \in B. As xx was arbitrary, AA and BB have the same elements, so by extensionality A=BA = B. ∎

The double-inclusion proof template. To prove two sets AA and BB are equal:

  1. (\subseteq) Assume xAx \in A; through valid steps deduce xBx \in B. Conclude ABA \subseteq B.
  2. (\supseteq) Assume xBx \in B; through valid steps deduce xAx \in A. Conclude BAB \subseteq A.
  3. By Theorem 1.13, A=BA = B. ∎

This template appears constantly in Lecture 2, where every set identity (De Morgan’s laws, distributivity, absorption, …) is proved this way.

5.3 Worked examples of set equality

Example 1.14 (order and repetition). {1,2,3}={3,2,1}={1,1,2,3}\{1, 2, 3\} = \{3, 2, 1\} = \{1, 1, 2, 3\}. All three descriptions list exactly the members 1,2,31, 2, 3; by extensionality they denote one set.

Example 1.15 (double inclusion, roster vs. set-builder). Let A={xZx2=1}A = \{\, x \in \mathbb{Z} \mid x^2 = 1 \,\} and B={1,1}B = \{-1, 1\}. We claim A=BA = B.

Proof. (\subseteq) Let xAx \in A. Then xZx \in \mathbb Z and x2=1x^2 = 1, so x21=0x^2 - 1 = 0, i.e. (x1)(x+1)=0(x-1)(x+1) = 0; hence x=1x = 1 or x=1x = -1. In either case xBx \in B. Thus ABA \subseteq B. (\supseteq) 1Z1 \in \mathbb Z and 12=11^2 = 1, so 1A1 \in A; likewise (1)2=1(-1)^2 = 1, so 1A-1 \in A. Hence BAB \subseteq A. By double inclusion, A=BA = B. ∎

Example 1.16 (two set-builder descriptions). Let

E={2kkZ},F={nZn2 is even}.E = \{\, 2k \mid k \in \mathbb{Z} \,\}, \qquad F = \{\, n \in \mathbb{Z} \mid n^2 \text{ is even} \,\}.

We claim E=FE = F (both are “the even integers”).

Proof. (\subseteq) Let nEn \in E, so n=2kn = 2k for some kZk \in \mathbb Z. Then n2=4k2=2(2k2)n^2 = 4k^2 = 2(2k^2) is even, so nFn \in F. (\supseteq) Let nFn \in F, so n2n^2 is even. If nn were odd, then n2n^2 would be odd (§1.3.1); since n2n^2 is even, nn must be even, i.e. n=2kn = 2k for some kZk \in \mathbb Z, so nEn \in E. Hence FEF \subseteq E, and E=FE = F. ∎

Example 1.17 (unequal sets — refute one inclusion). {1,2,3}{1,2}\{1, 2, 3\} \ne \{1, 2\}, because 33 belongs to the first set but not the second, so the inclusion {1,2,3}{1,2}\{1,2,3\} \subseteq \{1,2\} fails. To show inequality it is enough to break one of the two inclusions.

Example 1.18 (element vs. singleton, revisited). 2{2}2 \ne \{2\}: the left side is a number, the right side is a set. Likewise {2}{{2}}\{2\} \ne \{\{2\}\}: the left side’s element is 22, the right side’s element is {2}\{2\}, and 2{2}2 \ne \{2\}.

Common pitfall (proving equality with only one inclusion). A frequent error is to prove ABA \subseteq B and stop, concluding A=BA = B. One inclusion gives only “AA is part of BB,” which is consistent with ABA \ne B. Both directions are needed. Conversely, when the two directions have identical-looking steps, say so explicitly (“by the symmetric argument”) rather than omitting a direction.


1.6 Ways to describe a set

There are three standard ways to specify which elements a set contains.

6.1 Roster (list) notation

List the elements explicitly between braces, e.g. A={2,4,6,8}A = \{2, 4, 6, 8\}. For a clear, unambiguous pattern an ellipsis is permitted: N={1,2,3,}\mathbb{N} = \{1, 2, 3, \dots\} or {2,4,6,,100}\{2, 4, 6, \dots, 100\}. Roster notation is only practical when the set is small or its pattern is obvious.

6.2 Set-builder (predicate) notation

Describe the elements by a property (predicate) P(x)P(x) they must satisfy:

A={xP(x)}(read: "all x such that P(x)").A = \{\, x \mid P(x) \,\} \qquad (\text{read: "all } x \text{ such that } P(x)").

Almost always a domain UU is supplied to keep the definition safe and definite (§1.12 explains why this matters):

A={xUP(x)}.A = \{\, x \in U \mid P(x) \,\}.

This separation form carves out of UU exactly the elements satisfying PP.

Notation. The bar \mid is read “such that.” Some texts — and a few later sections here — write a colon instead, {x:P(x)}\{\, x : P(x) \,\}; the two are interchangeable.

A second, closely related form specifies elements by an expression ranging over a domain — the image or replacement form:

{f(x)xD},e.g.{n2nN}={1,4,9,16,}.\{\, f(x) \mid x \in D \,\}, \qquad\text{e.g.}\qquad \{\, n^2 \mid n \in \mathbb{N} \,\} = \{1, 4, 9, 16, \dots\}.

Here the bar separates a rule for producing elements (left) from the range of the input (right).

Example 1.19. The roster {2,4,6,8,10}\{2, 4, 6, 8, 10\} equals the set-builder description {xNx is even and x10}\{\, x \in \mathbb{N} \mid x \text{ is even and } x \le 10 \,\}.

Example 1.20 (roster impossible). {xRx2<9}\{\, x \in \mathbb{R} \mid x^2 < 9 \,\} is the open interval (3,3)(-3, 3). Roster notation cannot express it (uncountably many elements — §1.9), so set-builder notation is essential, not merely convenient.

Example 1.21 (empty via unsatisfiable predicate). {xRx2=1}=\{\, x \in \mathbb{R} \mid x^2 = -1 \,\} = \varnothing, since no real number squares to a negative value. A set-builder description names \varnothing precisely when its predicate is unsatisfiable over the domain.

Example 1.22 (congruences). {xZx1(mod3)}={,5,2,1,4,7,}\{\, x \in \mathbb{Z} \mid x \equiv 1 \pmod 3 \,\} = \{\dots, -5, -2, 1, 4, 7, \dots\}, the integers leaving remainder 11 on division by 33. Such sets (residue classes) reappear in the number-theory and modular-arithmetic material.

Example 1.23 (a set of pairs). {(x,y)R2x2+y2=1}\{\, (x,y) \in \mathbb{R}^2 \mid x^2 + y^2 = 1 \,\} is the unit circle in the plane. Set-builder notation ranges naturally over tuples (§1.11), which is how curves, relations, and graphs get defined.

Example 1.24 (the rationals). Q={pqp,qZ, q0}\mathbb{Q} = \{\, \tfrac{p}{q} \mid p, q \in \mathbb{Z},\ q \ne 0 \,\}. Note this uses the image form; many different pairs (p,q)(p,q) name the same rational (12=24\tfrac12 = \tfrac24), which is fine — extensionality collapses the duplicates.

Common pitfall (unrestricted comprehension). Writing {xP(x)}\{\,x \mid P(x)\,\} with no domain — quantifying over “all objects whatsoever” — is dangerous. Taking P(x)P(x) to be “xxx \notin x” produces Russell’s paradoxical set (§1.12). Modern set theory only permits the separation form {xUP(x)}\{\,x \in U \mid P(x)\,\}, carving from a set UU already known to exist. In this course, always give the domain.

6.3 Recursive (inductive) definition

Give base elements and rules that generate new elements from old ones. This third style is important enough — and central enough to computer science — to get its own section.


1.7 Recursive (inductive) definitions

7.1 Motivation and the three parts

How do you define an infinite set precisely, using only finitely many words, without a closed formula? You bootstrap: declare a few elements outright, then give rules that manufacture new elements from ones you already have. This is exactly how programmers define linked lists (“a list is empty, or a head followed by a list”), how compilers define the syntax of expressions, and how logicians define formulas.

Definition (recursive/inductive definition). A recursive definition of a set SS has three parts:

  • a base case (basis) — one or more elements declared to be in SS outright;
  • a recursive rule (induction step) — how to build new elements of SS from elements already known to be in SS;
  • a closure clauseSS contains nothing except what the basis and rules force (usually left implicit).

The closure clause matters: without it, “the set containing 22 and closed under +2+2” could be {2,4,6,}\{2,4,6,\dots\} or all of Z\mathbb Z or all of R\mathbb R. Closure makes SS the smallest set satisfying the basis and rule.

A recursive definition generating strings as a tree from basis, rule, and closure

7.2 Examples

Example 1.25 (positive even numbers). Define EE by basis 2E2 \in E; rule if nEn \in E then n+2En+2 \in E. Applying the rule repeatedly gives 2,4,6,8,2, 4, 6, 8, \dots, so E={2kkN}E = \{\, 2k \mid k \in \mathbb{N} \,\}.

Example 1.26 (powers of two). Basis 1S1 \in S; rule if xSx \in S then 2xS2x \in S. This generates S={1,2,4,8,16,}={2kkN0}S = \{1, 2, 4, 8, 16, \dots\} = \{\,2^{k} \mid k \in \mathbb{N}_0\,\}.

Example 1.27 (strings over an alphabet). Fix a finite alphabet Σ\Sigma (e.g. Σ={0,1}\Sigma = \{0,1\}). The set Σ\Sigma^{*} of all finite strings is defined by basis the empty string εΣ\varepsilon \in \Sigma^{*}; rule if wΣw \in \Sigma^{*} and aΣa \in \Sigma then the concatenation waΣwa \in \Sigma^{*}. This is the founding definition of formal-language theory (used heavily in the lectures on regular languages and automata): a language is then simply a subset of Σ\Sigma^{*}.

Example 1.28 (balanced parentheses / the Dyck language). Over Σ={(,)}\Sigma = \{\,(\,,\,)\,\}, define DD by: basis εD\varepsilon \in D; rules if wDw \in D then (w)D(w) \in D, and if w1,w2Dw_1, w_2 \in D then w1w2Dw_1 w_2 \in D. Then DD is exactly the set of correctly-nested parenthesis strings: ε\varepsilon, (), (()), ()(), (()()), … Recursively-defined languages like this are what parsers recognize.

Example 1.29 (arithmetic expressions). Over operands {a,b,c}\{a, b, c\} and operators {+,×}\{+, \times\}: basis each of a,b,ca, b, c is an expression; rule if E1E_1 and E2E_2 are expressions then so are (E1+E2)(E_1 + E_2) and (E1×E2)(E_1 \times E_2). This generates all fully-parenthesized expressions such as ((a+b)×c)((a+b)\times c) — the abstract syntax that every compiler builds.

Example 1.30 (binary trees). Basis the empty tree \bullet is a binary tree; rule if LL and RR are binary trees then the ordered triple L,r,R\langle L,\, r,\, R\rangle (left subtree, root, right subtree) is a binary tree. Data structures are recursively-defined sets; this is why they pair so naturally with recursion and induction in code.

Remark (structural induction). Every recursively-defined set comes with a matching proof method: to show every element of SS has a property QQ, prove QQ holds for the basis elements and is preserved by each rule. This is structural induction, the generalization of ordinary induction on N\mathbb N, developed in the lecture on mathematical induction. For instance, one proves “every string in the Dyck language DD has equally many ( and )” by structural induction on the definition in Example 1.28.

Remark (the natural numbers are themselves recursive). Even N\mathbb N can be built recursively. In the von Neumann construction one sets 0=0 = \varnothing and n+1=n{n}n + 1 = n \cup \{n\}, so

0=,1={},2={,{}},3={,{},{,{}}},0 = \varnothing,\quad 1 = \{\varnothing\},\quad 2 = \{\varnothing,\{\varnothing\}\},\quad 3 = \{\varnothing,\{\varnothing\},\{\varnothing,\{\varnothing\}\}\}, \dots

Each number is the set of all smaller numbers, so n=n|n| = n. This shows sets are expressive enough to encode the counting numbers themselves — the whole of mathematics can, in principle, be founded on the single relation \in.


1.8 Cardinality — the “power” of a set

8.1 Counting elements

Definition (cardinality). The cardinality of a set AA, denoted A|A|, is the number of elements it contains. A set is finite if A=n|A| = n for some n{0,1,2,}n \in \{0, 1, 2, \dots\}, and infinite otherwise.

(In older texts and the course deck, cardinality is called the power of a set — Cantor’s original German term was Mächtigkeit. The unrelated “power set” of §1.10 borrows the same word.)

  • =0|\varnothing| = 0.
  • {a,b,c}=3|\{a, b, c\}| = 3.
  • {1,1,2}=2|\{1, 1, 2\}| = 2 — duplicates are not counted twice (extensionality).
  • {,{}}=2|\{\varnothing, \{\varnothing\}\}| = 2 — two distinct elements.

Example 1.31. For A={a,e,i,o,u}A = \{a, e, i, o, u\} we have A=5|A| = 5. For B={xZ2x2}={2,1,0,1,2}B = \{\, x \in \mathbb{Z} \mid -2 \le x \le 2 \,\} = \{-2,-1,0,1,2\} we have B=5|B| = 5 as well. So A=B|A| = |B| even though ABA \ne B: cardinality measures how many, not which.

8.2 Equinumerosity: comparing sizes with bijections

Example 1.31 hints at the deep idea that drives the rest of this chapter: two sets have the “same size” when their elements can be matched up one-to-one, with none left over on either side. This matching idea — not counting — is what generalizes to infinite sets.

Definition (equinumerous). Sets AA and BB are equinumerous, written A=B|A| = |B|, if there is a bijection f:ABf : A \to B (a function that is both injective — no two inputs share an output — and surjective — every output is hit). We write AB|A| \le |B| if there is an injection ABA \to B.

For finite sets this agrees with ordinary counting. Its power is that it needs no notion of “number” at all, so it applies to infinite sets, where it produces genuinely surprising results (§1.9). Functions, injectivity, surjectivity, and bijectivity are defined here as we need them, as counting tools; functions in their own right appear as a special kind of relation in Lecture 3 (§3.12).

Remark. Exhibiting a bijection is the gold-standard way to prove two sets have equal size — you will see it used to prove P(A)=2n|\mathcal{P}(A)| = 2^{n} in §1.10 and A×B=AB|A \times B| = |A|\,|B| in §1.11, and it underlies the combinatorial “bijective proofs” in the combinatorics of Lecture 13.


1.9 Countable and uncountable sets

9.1 Are all infinities the same size?

Here is one of the most beautiful discoveries in mathematics, due to Georg Cantor (1870s–1880s): there are different sizes of infinity. The infinite set N\mathbb{N} can be matched one-to-one with Z\mathbb Z and even with Q\mathbb Q, but cannot be matched with R\mathbb R — the reals are strictly more numerous. We sketch why. These facts are not needed arithmetically in the rest of the course, but the distinction between countable and uncountable is genuinely used: e.g. the set of all programs is countable while the set of all functions N{0,1}\mathbb N \to \{0,1\} is uncountable, which is the seed of the existence of uncomputable functions (a theme of the computability material).

ℕ pairs one-to-one with ℤ (countable), while ℝ defeats any listing by diagonalization (uncountable)

Definition (countable / uncountable). A set AA is countably infinite if A=N|A| = |\mathbb{N}|, i.e. there is a bijection NA\mathbb{N} \to A — equivalently, AA’s elements can be arranged in an infinite list a1,a2,a3,a_1, a_2, a_3, \dots with each element appearing exactly once. A set is countable if it is finite or countably infinite, and uncountable otherwise. The cardinality of N\mathbb N is written 0\aleph_0 (“aleph-null”).

9.2 Z\mathbb{Z} and Q\mathbb{Q} are countable

Theorem 1.32. Z\mathbb{Z} is countably infinite.

Proof. We exhibit a bijection f:NZf : \mathbb{N} \to \mathbb{Z} by listing the integers so that each appears exactly once:

0, 1, 1, 2, 2, 3, 3, 0,\ 1,\ -1,\ 2,\ -2,\ 3,\ -3,\ \dots

Explicitly, f(n)=n2f(n) = \dfrac{n}{2} if nn is even, and f(n)=1n2f(n) = \dfrac{1-n}{2} if nn is odd (recall N={1,2,3,}\mathbb N = \{1,2,3,\dots\}). Then f(1)=0, f(2)=1, f(3)=1, f(4)=2, f(5)=2,f(1)=0,\ f(2)=1,\ f(3)=-1,\ f(4)=2,\ f(5)=-2,\dots Every integer appears exactly once — the non-positive integers at odd inputs, the positive integers at even inputs — so ff is a bijection. Hence Z=N=0|\mathbb Z| = |\mathbb N| = \aleph_0. ∎

The lesson is counterintuitive: Z\mathbb Z “looks twice as big” as N\mathbb N, yet the two are equinumerous. With infinite sets, a proper subset can have the same cardinality as the whole (indeed this is a characterization of infinity).

Theorem 1.33 (Cantor). Q\mathbb{Q} is countably infinite.

Proof sketch. Arrange the positive rationals pq\tfrac{p}{q} (p,qNp, q \in \mathbb{N}) in an infinite grid, row pp and column qq:

111213142122232431323334\begin{array}{ccccc} \tfrac11 & \tfrac12 & \tfrac13 & \tfrac14 & \cdots\\ \tfrac21 & \tfrac22 & \tfrac23 & \tfrac24 & \cdots\\ \tfrac31 & \tfrac32 & \tfrac33 & \tfrac34 & \cdots\\ \vdots & \vdots & \vdots & \vdots & \ddots \end{array}

Traverse the grid along successive anti-diagonals (11; 21,12; 31,22,13; \tfrac11;\ \tfrac21,\tfrac12;\ \tfrac31,\tfrac22,\tfrac13;\ \dots), skipping any fraction not in lowest terms (so each rational is counted once). This lists every positive rational: Q+\mathbb Q^{+} is countable. Now interleave with 00 and the negatives — 0,q1,q1,q2,q2,0, q_1, -q_1, q_2, -q_2, \dots — to list all of Q\mathbb Q. Hence Q\mathbb Q is countably infinite. ∎

The same anti-diagonal “dovetailing” shows that a countable union of countable sets is countable, and that N×N\mathbb N \times \mathbb N is countable — facts reused throughout computer science (e.g. enumerating all pairs, all strings, all programs).

9.3 R\mathbb{R} is uncountable: Cantor’s diagonal argument

Now the punchline: no list can exhaust the reals.

Theorem 1.34 (Cantor, 1891). The interval (0,1)R(0,1) \subseteq \mathbb{R} is uncountable. Consequently R\mathbb{R} is uncountable.

Proof (diagonalization). Suppose, for contradiction, that (0,1)(0,1) is countable. Then its elements can be listed as a sequence x1,x2,x3,x_1, x_2, x_3, \dots containing every number in (0,1)(0,1). Write each in decimal:

x1=0.d11d12d13d14x2=0.d21d22d23d24x3=0.d31d32d33d34x4=0.d41d42d43d44\begin{array}{lcl} x_1 &=& 0.\,\mathbf{d_{11}}\,d_{12}\,d_{13}\,d_{14}\cdots\\ x_2 &=& 0.\,d_{21}\,\mathbf{d_{22}}\,d_{23}\,d_{24}\cdots\\ x_3 &=& 0.\,d_{31}\,d_{32}\,\mathbf{d_{33}}\,d_{34}\cdots\\ x_4 &=& 0.\,d_{41}\,d_{42}\,d_{43}\,\mathbf{d_{44}}\cdots\\ &\vdots& \end{array}

where dij{0,1,,9}d_{ij} \in \{0,1,\dots,9\} is the jj-th decimal digit of xix_i. Now construct a new number y=0.e1e2e3y = 0.\,e_1 e_2 e_3 \cdots by altering the diagonal digits diid_{ii} (shown in bold):

ei  =  {5if dii5,6if dii=5.e_i \;=\; \begin{cases} 5 & \text{if } d_{ii} \ne 5,\\[2pt] 6 & \text{if } d_{ii} = 5.\end{cases}

By construction y(0,1)y \in (0,1), and eidiie_i \ne d_{ii} for every ii. Therefore yy differs from xix_i in the ii-th decimal place, for every ii, so yxiy \ne x_i for all ii. But the list was supposed to contain every element of (0,1)(0,1), and y(0,1)y \in (0,1) — contradiction. Hence (0,1)(0,1) cannot be listed: it is uncountable. Since (0,1)R(0,1) \subseteq \mathbb R, the larger set R\mathbb R is uncountable as well. ∎

Remark (why the digits 55 and 66). A real number can have two decimal expansions only when one ends in all $9$s and the other in all $0$s (e.g. 0.4999=0.50000.4999\ldots = 0.5000\ldots). We chose ei{5,6}e_i \in \{5,6\} precisely so that yy uses no $0$s or $9$s; hence yy has a unique decimal expansion, and the guarantee “yy differs from xix_i at digit ii” cannot be voided by an alternate expansion of xix_i. This care is what makes the argument airtight rather than merely suggestive.

Remark (the continuum). Cantor’s argument shows N<R|\mathbb N| < |\mathbb R|: the reals form a strictly larger infinity, the continuum. So the “gap” between Q\mathbb Q and R\mathbb R that Theorem 1.7 opened for the single number 2\sqrt 2 is in fact enormous — the irrationals are uncountable, while the rationals we can list are, in this precise sense, negligibly few.

9.4 Cantor’s theorem: the power set is always bigger

Diagonalization is not a trick special to decimals; it is a general phenomenon.

Theorem 1.35 (Cantor’s theorem). For every set AA, there is no surjection f:AP(A)f : A \to \mathcal{P}(A). Consequently A<P(A)|A| < |\mathcal{P}(A)| — a set always has strictly fewer elements than its power set, even when AA is infinite.

Proof. Let f:AP(A)f : A \to \mathcal{P}(A) be any function; we show ff misses some subset. Define the “diagonal” set

D={xAxf(x)}A,so DP(A).D = \{\, x \in A \mid x \notin f(x) \,\} \subseteq A, \quad\text{so } D \in \mathcal{P}(A).

Suppose DD were in the image of ff, say D=f(a)D = f(a) for some aAa \in A. Ask whether aDa \in D. By the definition of DD,

aD    af(a)    aD,a \in D \iff a \notin f(a) \iff a \notin D,

since f(a)=Df(a) = D. Thus “aDa \in D” holds iff it fails — a contradiction. So no such aa exists, DD is not in the image of ff, and ff is not surjective. As no surjection AP(A)A \to \mathcal{P}(A) exists (while x{x}x \mapsto \{x\} is an injection AP(A)A \to \mathcal{P}(A)), we conclude A<P(A)|A| < |\mathcal{P}(A)|. ∎

Taking A=NA = \mathbb N yields N<P(N)|\mathbb N| < |\mathcal{P}(\mathbb N)|, so P(N)\mathcal{P}(\mathbb N) is uncountable (in fact P(N)=R|\mathcal{P}(\mathbb N)| = |\mathbb R|). Iterating, A<P(A)<P(P(A))<|A| < |\mathcal{P}(A)| < |\mathcal{P}(\mathcal{P}(A))| < \cdots: there is no largest infinity. Notice, too, how the diagonal set DD in this proof is the very same self-referential construction that produces Russell’s paradox in §1.12 — the two are the same idea wearing different clothes.

Historical note. Cantor’s creation of set theory and his hierarchy of infinities were revolutionary and, at first, fiercely resisted. Today his diagonal method is a cornerstone not only of set theory but of computability (the undecidability of the halting problem is a diagonal argument) and of logic (Gödel’s incompleteness theorems).


1.10 The power set

10.1 Definition and examples

Since subsets of a set AA are themselves objects, we may collect all of them into a new set.

Definition (power set). The power set of AA, written P(A)\mathcal{P}(A) (also P(A)P(A) or 2A2^{A}), is the set of all subsets of AA:

P(A)={SSA}.\mathcal{P}(A) = \{\, S \mid S \subseteq A \,\}.

Its elements are themselves sets. Both \varnothing and AA always belong to P(A)\mathcal{P}(A) (by Proposition 1.9 and 4.2).

The power set athcal{P}({a,b,c}) as a lattice of all 2³ = 8 subsets ordered by inclusion

Example 1.36. P()={}\mathcal{P}(\varnothing) = \{\varnothing\} — one element (not zero!), so P()=1|\mathcal{P}(\varnothing)| = 1. And P({a})={,{a}}\mathcal{P}(\{a\}) = \{\varnothing, \{a\}\}, with P({a})=2|\mathcal{P}(\{a\})| = 2. And P({a,b})={,{a},{b},{a,b}}\mathcal{P}(\{a,b\}) = \{\varnothing, \{a\}, \{b\}, \{a,b\}\}, with P({a,b})=4|\mathcal{P}(\{a,b\})| = 4.

Example 1.37 (from the deck). For A={1,2,3,4}A = \{1, 2, 3, 4\}, the power set has 1616 members:

P(A)={ , {1},{2},{3},{4}, {1,2},{1,3},{1,4},{2,3},{2,4},{3,4},\mathcal{P}(A) = \Big\{\ \varnothing,\ \{1\},\{2\},\{3\},\{4\},\ \{1,2\},\{1,3\},\{1,4\},\{2,3\},\{2,4\},\{3,4\},

{1,2,3},{1,2,4},{1,3,4},{2,3,4}, {1,2,3,4} }.\{1,2,3\},\{1,2,4\},\{1,3,4\},\{2,3,4\},\ \{1,2,3,4\}\ \Big\}.

Grouped by size: one subset of size 00, four of size 11, six of size 22, four of size 33, and one of size 44 — a total of 1+4+6+4+1=161+4+6+4+1 = 16.

Common pitfall. P()=1|\mathcal{P}(\varnothing)| = 1, not 00: the empty set has exactly one subset, namely itself. Similarly P(A)\varnothing \in \mathcal{P}(A) for every AA, so P(A)\mathcal{P}(A) is never empty even when AA is.

10.2 The size of the power set

The grouping in Example 1.37 (with row sums 1,4,6,4,11,4,6,4,1 — the binomial coefficients (4k)\binom{4}{k}) points to the central theorem. We give two independent proofs, because each teaches a reusable technique.

Theorem 1.38. If AA is finite with A=n|A| = n, then P(A)=2n|\mathcal{P}(A)| = 2^{n}.

Proof 1 — by a bijection with bit-strings

Proof. List the elements as A={a1,a2,,an}A = \{a_1, a_2, \dots, a_n\}. Let {0,1}n\{0,1\}^{n} be the set of length-nn bit-strings (ordered nn-tuples of $0$s and $1$s). Define φ:P(A){0,1}n\varphi : \mathcal{P}(A) \to \{0,1\}^{n} by sending each subset SS to its characteristic vector

φ(S)=(b1,b2,,bn),bi={1if aiS,0if aiS.\varphi(S) = (b_1, b_2, \dots, b_n), \qquad b_i = \begin{cases} 1 & \text{if } a_i \in S,\\ 0 & \text{if } a_i \notin S.\end{cases}

We show φ\varphi is a bijection.

  • Injective. Suppose φ(S)=φ(T)\varphi(S) = \varphi(T). Then for each ii, aiS    bi=1    aiTa_i \in S \iff b_i = 1 \iff a_i \in T. So SS and TT contain exactly the same aia_i, i.e. S=TS = T.
  • Surjective. Given any bit-string (b1,,bn){0,1}n(b_1,\dots,b_n) \in \{0,1\}^{n}, form S={aibi=1}AS = \{\, a_i \mid b_i = 1 \,\} \subseteq A. Then φ(S)=(b1,,bn)\varphi(S) = (b_1,\dots,b_n). So every bit-string is hit.

Hence φ\varphi is a bijection, and P(A)={0,1}n|\mathcal{P}(A)| = |\{0,1\}^{n}|. Finally {0,1}n=2n|\{0,1\}^{n}| = 2^{n}: a length-nn bit-string is built by choosing each of the nn coordinates independently from 22 options, so by the product rule (Lecture 13’s combinatorics) there are 222=2n2 \cdot 2 \cdots 2 = 2^{n} of them. Therefore P(A)=2n|\mathcal{P}(A)| = 2^{n}. ∎

This bijection is not merely a counting device — it is how sets are stored in computers (§1.11.4 / §1.13): a subset of an nn-element universe is a single nn-bit word.

Proof 2 — by induction on nn

Proof. We induct on n=An = |A|.

Base case (n=0n = 0). The only set with 00 elements is \varnothing, and P()={}\mathcal{P}(\varnothing) = \{\varnothing\}, so P()=1=20|\mathcal{P}(\varnothing)| = 1 = 2^{0}. ✓

Inductive step. Assume (induction hypothesis) that every set with kk elements has exactly 2k2^{k} subsets. Let AA be any set with A=k+1|A| = k+1. Fix an element aAa \in A and put A=A{a}A' = A \setminus \{a\}, so A=k|A'| = k. Split the subsets of AA into two classes according to whether they contain aa:

  • Subsets not containing aa. These are precisely the subsets of AA'. By the induction hypothesis there are 2k2^{k} of them.
  • Subsets containing aa. Each has the form S{a}S \cup \{a\} for a unique SAS \subseteq A', and conversely each SAS \subseteq A' yields one such subset. This pairing is a bijection with the subsets of AA', so again there are 2k2^{k}.

The two classes are disjoint (a set either contains aa or not) and together exhaust P(A)\mathcal{P}(A). By the sum rule,

P(A)=2k+2k=22k=2k+1.|\mathcal{P}(A)| = 2^{k} + 2^{k} = 2 \cdot 2^{k} = 2^{k+1}.

This completes the inductive step. By the principle of mathematical induction, P(A)=2n|\mathcal{P}(A)| = 2^{n} for all n0n \ge 0. ∎

Remark (why prove it twice). The bijective proof gives insight — subsets “are” bit-strings — and generalizes to a formula-free count. The inductive proof models the standard “fix one element, split into two cases” strategy that recurs across combinatorics. Meeting both now prepares you for the combinatorics of Lecture 13.

Corollary 1.39 (a binomial identity). For every n0n \ge 0,

k=0n(nk)=2n.\sum_{k=0}^{n} \binom{n}{k} = 2^{n}.

Proof. Classify the subsets of an nn-set by their size kk. The number of kk-element subsets is (nk)\binom{n}{k} (this is the definition of the binomial coefficient, established in the combinatorics of Lecture 13). Summing over all possible sizes k=0,1,,nk = 0, 1, \dots, n counts every subset exactly once, which by Theorem 1.38 totals 2n2^{n}. ∎ For n=4n = 4 this reads 1+4+6+4+1=161+4+6+4+1 = 16, matching Example 1.37 exactly.

Remark (the notation 2A2^{A}). The alternative symbol 2A2^{A} for the power set is deliberate: writing 2={0,1}2 = \{0,1\}, the set 2A2^{A} of all functions A{0,1}A \to \{0,1\} is (via characteristic functions) the set of subsets of AA, and its size 2A2^{|A|} matches. This viewpoint also gives meaning to P(A)|\mathcal{P}(A)| for infinite AA: P(N)=20|\mathcal{P}(\mathbb N)| = 2^{\aleph_0}, the continuum of §1.9.


10.3 The power set and the set operations

The power set interacts cleanly with the operations of Lecture 2. For all sets A,BA,B:

  • P(AB)=P(A)P(B)\mathcal{P}(A\cap B)=\mathcal{P}(A)\cap\mathcal{P}(B) — a set is a subset of both AA and BB exactly when it is a subset of ABA\cap B;
  • P(A)P(B)P(AB)\mathcal{P}(A)\cup\mathcal{P}(B)\subseteq\mathcal{P}(A\cup B), and the inclusion is usually strict: {a,b}P({a}{b})\{a,b\}\in\mathcal{P}(\{a\}\cup\{b\}) but lies in neither P({a})\mathcal{P}(\{a\}) nor P({b})\mathcal{P}(\{b\});
  • P(A)P(B)    AB\mathcal{P}(A)\subseteq\mathcal{P}(B)\iff A\subseteq Bmonotonicity, since AP(A)A\in\mathcal{P}(A) then forces AP(B)A\in\mathcal{P}(B), i.e. ABA\subseteq B.

Each is a one-line element-chase: rewrite “XP()X\in\mathcal{P}(\cdot)” as “XX\subseteq\cdot” and unfold the definitions of ,,\cap,\cup,\subseteq.

1.11 Ordered pairs, tuples, and the Cartesian product

11.1 When order matters

Sets deliberately forget order, but a great deal of mathematics and computing needs to remember it: the point (3,5)(3,5) in the plane is not (5,3)(5,3); the database row ("Ada", 1815) pairs a name with a year in a fixed layout; a function’s input \to output pairing is directional. For this we use ordered pairs.

Definition (ordered pair). An ordered pair (a,b)(a, b) records a first component aa and a second component bb. Its defining property is that order is significant:

(a,b)=(c,d)        a=c and b=d.(a, b) = (c, d) \;\iff\; a = c \ \text{and}\ b = d.

In particular (1,2)(2,1)(1, 2) \ne (2, 1), whereas the sets {1,2}\{1,2\} and {2,1}\{2,1\} are equal. Repetition is allowed in a pair: (1,1)(1,1) is perfectly valid, though {1,1}={1}\{1,1\} = \{1\} as a set.

Remark (pairs are secretly sets — Kuratowski). Ordered pairs need not be a new primitive; they can be encoded as sets. Kuratowski’s definition is

(a,b):={{a}, {a,b}}.(a,b) := \{\, \{a\},\ \{a,b\} \,\}.

One can prove from this that (a,b)=(c,d)    a=cb=d(a,b) = (c,d) \iff a=c \wedge b=d, recovering exactly the defining property. This is a recurring theme: with enough ingenuity, every discrete structure (pairs, numbers, functions, relations) can be built out of plain sets and the single relation \in. We will use pairs as if primitive and never unfold the encoding.

Definition (nn-tuple). For n1n \ge 1, an nn-tuple (a1,a2,,an)(a_1, a_2, \dots, a_n) is an ordered list of nn components. Two nn-tuples are equal iff they agree in every coordinate:

(a1,,an)=(b1,,bn)    ai=bi for all i.(a_1,\dots,a_n) = (b_1,\dots,b_n) \iff a_i = b_i \text{ for all } i.

Ordered pairs are the case n=2n = 2; a 33-tuple (x,y,z)(x,y,z) locates a point in space.

11.2 The Cartesian product

Definition (Cartesian product). The Cartesian product of sets AA and BB is the set of all ordered pairs with first component from AA and second from BB:

A×B={(a,b)aA, bB}.A \times B = \{\, (a, b) \mid a \in A,\ b \in B \,\}.

More generally, A1×A2××An={(a1,,an)aiAi}A_1 \times A_2 \times \cdots \times A_n = \{\,(a_1,\dots,a_n) \mid a_i \in A_i\,\}, and AnA^{n} abbreviates A×A××AA \times A \times \cdots \times A (nn factors).

The name honors René Descartes, whose coordinate geometry identifies the plane with R×R=R2\mathbb R \times \mathbb R = \mathbb{R}^{2} and space with R3\mathbb R^{3}.

The Cartesian product A × B as a grid of ordered pairs, with |A × B| = |A|·|B|

Example 1.40. With A={1,2,3,4}A = \{1, 2, 3, 4\} and B={1,2,3,4}B = \{1, 2, 3, 4\}, a typical element of A×BA \times B is (1,2)(1, 2), and (1,2)(2,1)(1,2) \ne (2,1) even though both pairs live in A×BA \times B. Here A×B=16|A \times B| = 16 (Proposition 1.42).

Example 1.41 (product need not be square). With A={a,b}A = \{a,b\} and B={1,2,3}B = \{1,2,3\},

A×B={(a,1),(a,2),(a,3),(b,1),(b,2),(b,3)},A \times B = \{(a,1),(a,2),(a,3),(b,1),(b,2),(b,3)\},

so A×B=23=6|A \times B| = 2 \cdot 3 = 6. Note A×BB×AA \times B \ne B \times A in general (their elements are pairs in opposite orders), so the Cartesian product is not commutative — one of several algebraic facts developed in Lecture 2.

11.3 Counting the product

Proposition 1.42. For finite sets, A×B=AB|A \times B| = |A| \cdot |B|.

Proof. Let A={a1,,am}A = \{a_1,\dots,a_m\} with A=m|A| = m and B=n|B| = n. Partition A×BA \times B according to the first coordinate:

A×B=({a1}×B)({a2}×B)({am}×B).A \times B = (\{a_1\}\times B) \,\cup\, (\{a_2\}\times B) \,\cup\, \cdots \,\cup\, (\{a_m\}\times B).

These mm blocks are pairwise disjoint (pairs with different first coordinates are different), and each block {ai}×B={(ai,b)bB}\{a_i\}\times B = \{(a_i, b) \mid b \in B\} is in bijection with BB via (ai,b)b(a_i,b) \mapsto b, so each has exactly nn elements. By the sum rule, A×B=n+n++nm=mn=AB|A \times B| = \underbrace{n + n + \cdots + n}_{m} = m \cdot n = |A|\cdot|B|. ∎

By induction this extends to A1××An=A1A2An|A_1 \times \cdots \times A_n| = |A_1|\cdot|A_2|\cdots|A_n|; in particular An=An|A^{n}| = |A|^{n}. For instance {0,1}n=2n|\{0,1\}^{n}| = 2^{n}, recovering the bit-string count used in Theorem 1.38.

Remark (cross-reference). The Cartesian product is the stage on which relations and functions are defined: in Lecture 3, a relation from AA to BB is any subset RA×BR \subseteq A \times B, and a function is a relation in which each aAa \in A appears as a first coordinate exactly once. Thus everything in this section is prerequisite machinery for the two lectures that follow.

11.4 A first glimpse of applications

The three constructions of this chapter map cleanly onto everyday computing objects:

  • a subset of a fixed finite universe ⟷ a bit-set / bitmask (§1.13.1);
  • a tuple ⟷ a record / struct / row (§1.13.2);
  • a Cartesian product ⟷ the type of all such rows (§1.13.2–13.3).

§1.13 develops these.


1.12 Russell’s paradox and a note on axioms

12.1 The paradox

The naive rule we have used informally — “any property PP determines the set {xP(x)}\{x \mid P(x)\} of all objects with that property” — is called unrestricted comprehension. In 1901 Bertrand Russell noticed it is self-contradictory.

Some sets are members of themselves and some are not — under naive comprehension, at least; e.g. “the set of all sets” would contain itself. Consider the property “xx is not a member of itself,” and form the set it supposedly determines:

R={xxx}.R = \{\, x \mid x \notin x \,\}.

Now ask the fatal question: is RRR \in R?

  • If RRR \in R, then RR satisfies the defining property, i.e. RRR \notin R.
  • If RRR \notin R, then RR satisfies the defining property, so RRR \in R.

Either way we reach RR    RRR \in R \iff R \notin R, an outright contradiction. So no such set RR can exist, and unrestricted comprehension is untenable. (The kinship with Cantor’s diagonal set DD in Theorem 1.35 is exact: both hinge on an object asked whether it belongs to a set defined by not belonging.)

A homelier version — the barber. In a certain village the barber shaves exactly those men who do not shave themselves. Does the barber shave himself? If he does, he shouldn’t; if he doesn’t, he must. The “barber” cannot exist — just as the set RR cannot.

12.2 The resolution

The fix is to forbid conjuring sets out of properties alone. Modern set theory (the Zermelo–Fraenkel axioms, ZF/ZFC) replaces unrestricted comprehension with the axiom schema of separation: from an already existing set UU you may carve

{xUP(x)},\{\, x \in U \mid P(x) \,\},

but you may not form {xP(x)}\{x \mid P(x)\} over the whole universe. Because the paradoxical RR needs to range over all objects, it is never constructed, and the contradiction disappears. There is also, provably, no set of all sets in ZFC — which is why §1.2 insisted the universal set UU is always a concrete set fixed by context, never “everything.”

This is exactly why, throughout this course, we write set-builder expressions with a domain: {xZ}\{x \in \mathbb Z \mid \dots\}, {xU}\{x \in U \mid \dots\}. The habit is not pedantry — it is the discipline that keeps set theory consistent.

Historical note. Russell communicated the paradox to Gottlob Frege in 1902, just as the second volume of Frege’s Grundgesetze der Arithmetik — which sought to found all of arithmetic on unrestricted comprehension — was in press. Frege’s stricken reply conceded the foundation had collapsed. The repair by Ernst Zermelo (1908) and Abraham Fraenkel (1920s) produced the ZFC axioms on which essentially all of contemporary mathematics is now built.


1.13 Applications in computer science

Sets are not just notation; the constructions above are implemented directly in hardware, databases, and programming languages.

13.1 Bit-sets (bitmasks)

Fix a universe of nn items indexed 0,1,,n10, 1, \dots, n-1. By the characteristic-vector bijection of Theorem 1.38, every subset SS corresponds to a length-nn bit-string, which fits in a machine integer (an nn-bit word). Set operations become single hardware instructions on that word:

Set concept Bit operation Cost
iSi \in S test bit ii: (w >> i) & 1 O(1)O(1)
ABA \cup B bitwise OR a | b O(1)O(1) per word
ABA \cap B bitwise AND a & b O(1)O(1) per word
A\overline{A} (complement in UU) bitwise NOT ~a O(1)O(1) per word
ABA \setminus B a & ~b O(1)O(1) per word
$ A $ (cardinality)

This is why a 6464-element universe is a natural unit: one subset per uint64. Bit-sets power register allocators, graph reachability, chess engines (“bitboards”), and the fast set operations behind search engines. Every identity we prove about ,,()\cup, \cap, \overline{(\cdot)} in Lecture 2 is simultaneously a theorem about these bit operations (the shared abstraction is Boolean algebra).

13.2 Relational databases

A database table with columns of types T1,T2,,TnT_1, T_2, \dots, T_n has rows that are nn-tuples in the Cartesian product T1×T2××TnT_1 \times T_2 \times \cdots \times T_n. The table itself is a finite subset of that product — i.e. exactly a relation (Lecture 3):

Students    Name×ID×Year.\texttt{Students} \;\subseteq\; \texttt{Name} \times \texttt{ID} \times \texttt{Year}.

Because rows form a set, duplicate rows collapse (extensionality) and row order is irrelevant — matching SQL’s SELECT DISTINCT and the fact that query results are unordered unless you add ORDER BY. The operations of relational algebra — union, intersection, difference, projection, selection, join — are set operations on these subsets of Cartesian products, so this lecture and Lecture 2 are the direct mathematical foundation of SQL.

13.3 Type systems and algebraic data types

In a typed programming language a type can be understood as the set of its values, and the type constructors mirror set constructions — the reason they are called algebraic data types:

Type construct Set analogue Cardinality
product / struct / record / tuple (A, B) A×BA \times B AB\lvert A\rvert \cdot \lvert B\rvert
sum / variant / enum / tagged union A + B disjoint union ABA \sqcup B A+B\lvert A\rvert + \lvert B\rvert
function type A -> B set of functions BAB^{A} BA\lvert B\rvert^{\lvert A\rvert}
unit type () singleton {}\{\ast\} 11
empty / Void type \varnothing 00

For example, the type Bool = {true, false} has cardinality 22; a pair (Bool, Bool) has 22=42\cdot 2 = 4 values; and Bool -> Bool has 22=42^{2} = 4 functions — precisely BA|B|^{|A|}. Counting a type’s inhabitants (its cardinality) tells you, for instance, how many cases a switch must handle to be exhaustive, and the isomorphisms of this algebra (e.g. A×1AA \times 1 \cong A, A+0AA + 0 \cong A) justify refactorings compilers perform automatically.

13.4 Formal languages (preview)

By Example 1.27 the set Σ\Sigma^{*} of strings over an alphabet is recursively defined, and a language is any subset LΣL \subseteq \Sigma^{*}. Since Σ\Sigma^* is countably infinite, it has uncountably many subsets (Theorem 1.35), so there are uncountably many languages — but only countably many finite descriptions (programs/grammars). By a counting argument, most languages have no finite description: an early hint, grounded entirely in this chapter, that uncomputable and undecidable problems must exist. This thread is picked up in the lectures on regular languages, automata, and computability.


Chapter summary

Set theory supplies the vocabulary for the entire course. A set is an unordered collection of distinct elements, fully determined by its members (extensionality), so order and repetition inside braces are invisible. Membership xAx \in A is the single primitive relation. Two sets among all others are singled out: the empty set \varnothing, which we proved is unique and is a subset of every set (by vacuous truth), and a context-dependent universe UU — never “everything,” lest Russell’s paradox strike.

We compare sets with inclusion \subseteq, a partial order (reflexive, transitive, antisymmetric), and we prove two sets equal by the double-inclusion method — showing each contains the other — which is the template for every set identity to come. Sets are described three ways: by roster, by set-builder predicate (always over a stated domain, to stay safe), and by recursive definitions with a basis, a rule, and a closure clause — the last being how computer science defines strings, expressions, and data structures, and the natural partner of proof by (structural) induction.

We measure sets by cardinality A|A|, comparing sizes via bijections. This idea scales to the infinite, where Cantor’s results overturn intuition: Z\mathbb Z and Q\mathbb Q are countable, but R\mathbb R is uncountable by the diagonal argument, and A<P(A)|A| < |\mathcal{P}(A)| for every set. The power set P(A)\mathcal{P}(A) of all subsets satisfies P(A)=2n|\mathcal{P}(A)| = 2^{n} when A=n|A| = n, which we proved twice — bijectively (subsets \leftrightarrow bit-strings) and by induction. Finally, ordered pairs, tuples, and the Cartesian product A×BA \times B (with A×B=AB|A \times B| = |A|\,|B|) restore the notion of order and set the stage for relations and functions. The same three constructions reappear as bit-sets, database tables, and program types.

Key facts.

  • Extensionality: A=B    (x)(xA    xB)A = B \iff (\forall x)(x \in A \iff x \in B); order and repetition are irrelevant.
  • \varnothing is unique, =0|\varnothing| = 0, and A\varnothing \subseteq A for every AA (vacuous truth); but {}\varnothing \ne \{\varnothing\} and P()=1|\mathcal{P}(\varnothing)| = 1.
  • Numeric hierarchy: NZQRC\mathbb N \subset \mathbb Z \subset \mathbb Q \subset \mathbb R \subset \mathbb C, each inclusion proper; 2Q\sqrt 2 \notin \mathbb Q.
  • AB    (x)(xAxB)A \subseteq B \iff (\forall x)(x \in A \Rightarrow x \in B); \subseteq is reflexive, transitive, antisymmetric.
  • Equality by double inclusion: A=B    (ABBA)A = B \iff (A \subseteq B \wedge B \subseteq A).
  • Descriptions: roster, set-builder {xUP(x)}\{x \in U \mid P(x)\}, recursive (basis + rule + closure).
  • P(A)=2A|\mathcal{P}(A)| = 2^{|A|}; k=0n(nk)=2n\sum_{k=0}^{n}\binom nk = 2^{n}.
  • Countable: N,Z,Q\mathbb N, \mathbb Z, \mathbb Q. Uncountable: R\mathbb R, P(N)\mathcal{P}(\mathbb N). Always A<P(A)|A| < |\mathcal{P}(A)| (Cantor).
  • (a,b)=(c,d)    a=cb=d(a,b) = (c,d) \iff a=c \wedge b=d; A×B=AB|A \times B| = |A|\cdot|B|; product is not commutative.
  • Never form {xP(x)}\{x \mid P(x)\} without a domain (Russell’s paradox).

Exercises

Warm-up

1. State the two principles (order, repetition) that make {2,1,2}\{2,1,2\}, {1,2}\{1,2\}, and {2,1}\{2,1\} all denote the same set. What single axiom underlies both?

2. Explain the difference between \varnothing, {}\{\varnothing\}, and {0}\{0\}. Give the cardinality of each.

3. Place each of 3, 0.75, 5, 4, 32i-3,\ 0.75,\ \sqrt5,\ 4,\ 3-2i into the smallest customary numeric set (N,Z,Q,R,C\mathbb N, \mathbb Z, \mathbb Q, \mathbb R, \mathbb C) that contains it.

4. For A={1,{2},{1,2}}A = \{1, \{2\}, \{1,2\}\}, decide each of: 1A1 \in A; 2A2 \in A; {2}A\{2\} \in A; {2}A\{2\} \subseteq A; {1,2}A\{1,2\} \in A; {1,2}A\{1,2\} \subseteq A; A\varnothing \subseteq A.

5. Is {1,2}\{1,2\} a proper subset of {1,2}\{1,2\}? Is it a subset? Justify both answers.

6. Compute P(A)|\mathcal{P}(A)| for A={a,b,c}A = \{a,b,c\} and list all 88 of its elements grouped by size.

7. Why is (2,5)(5,2)(2,5) \ne (5,2) while {2,5}={5,2}\{2,5\} = \{5,2\}? How many elements does A×BA \times B have when A=3|A| = 3 and B=4|B| = 4?

Standard

8. Prove by double inclusion that {xZx2=4}={2,2}\{\, x \in \mathbb Z \mid x^2 = 4 \,\} = \{-2, 2\}.

9. Rewrite {3,6,9,12,15}\{3, 6, 9, 12, 15\} in set-builder notation, and give a recursive definition (basis + rule) of the set of all positive multiples of 33.

10. Let A={nZn=4k+2 for some kZ}A = \{n \in \mathbb Z \mid n = 4k+2 \text{ for some } k \in \mathbb Z\} and B={nZn2(mod4)}B = \{n \in \mathbb Z \mid n \equiv 2 \pmod 4\}. Prove A=BA = B.

11. Prove that for all sets, ABA \subseteq B and BCB \subseteq C imply ACA \subseteq C (transitivity), taking arbitrary elements explicitly.

12. List all elements of {a,b}×{1,2,3}\{a, b\} \times \{1, 2, 3\}, and separately of {1,2,3}×{a,b}\{1,2,3\} \times \{a,b\}. Are the two products equal? What does this show about commutativity of ×\times?

13. Using the recursive definition of the Dyck language (Example 1.28), list all balanced-parenthesis strings of length 4\le 4, and state how many there are of length exactly 66.

14. A byte is a bit-string of length 88. Using the characteristic-vector idea, explain why there are exactly 256256 subsets of an 88-element universe, and describe which byte represents the subset {a0,a3,a7}\{a_0, a_3, a_7\} of {a0,,a7}\{a_0, \dots, a_7\}.

Challenge

15. Prove that 3\sqrt 3 is irrational. Where exactly does the proof use that 33 is prime (equivalently, not a perfect square)?

16. Prove carefully that A\varnothing \subseteq A for every set AA by contradiction, writing out the negation of “A\varnothing \subseteq A” explicitly before deriving the contradiction.

17. Give the two proofs that P(A)=2n|\mathcal{P}(A)| = 2^{n} (bijection with bit-strings; and induction on nn) in your own words. In the inductive step, identify precisely where the induction hypothesis is used.

18. Prove that the set N×N\mathbb N \times \mathbb N is countable by describing an explicit listing (e.g. by anti-diagonals). Then explain in one or two sentences why the same style of argument fails to list the reals in (0,1)(0,1).

19. (Cantor’s theorem, hands-on.) Let A={1,2,3}A = \{1,2,3\} and let f:AP(A)f : A \to \mathcal{P}(A) be f(1)={2}, f(2)={1,2,3}, f(3)=f(1) = \{2\},\ f(2) = \{1,2,3\},\ f(3) = \varnothing. Compute the diagonal set D={xAxf(x)}D = \{x \in A \mid x \notin f(x)\} and verify explicitly that Df(x)D \ne f(x) for every xAx \in A.

20. Explain why the set R={xxx}R = \{x \mid x \notin x\} cannot exist. Then explain in one sentence how the ZFC separation axiom ({xUP(x)}\{x \in U \mid P(x)\}, with UU a set) blocks the paradox.


Selected answers & hints

2. =0|\varnothing| = 0 (no elements); {}=1|\{\varnothing\}| = 1 (one element, namely \varnothing); {0}=1|\{0\}| = 1 (one element, the number 00). All three are different objects: an empty box, a box holding an empty box, and a box holding the number zero.

4. True: 1A1 \in A, {2}A\{2\} \in A, {1,2}A\{1,2\} \in A, A\varnothing \subseteq A. False: 2A2 \in A (the object 22 is not an element of AA; it only appears inside elements), {2}A\{2\} \subseteq A (this would need 2A2 \in A, which is false), {1,2}A\{1,2\} \subseteq A (needs 2A2 \in A). Moral: distinguish \in from \subseteq, and do not “see through” braces.

5. {1,2}{1,2}\{1,2\} \subseteq \{1,2\} is true (reflexivity, Prop. 4.2: every element of the left is in the right). It is not a proper subset, because properness requires the two sets to differ, and here they are equal.

6. P(A)=23=8|\mathcal{P}(A)| = 2^3 = 8: \varnothing; {a},{b},{c}\{a\},\{b\},\{c\}; {a,b},{a,c},{b,c}\{a,b\},\{a,c\},\{b,c\}; {a,b,c}\{a,b,c\} — grouped 1+3+3+1=81 + 3 + 3 + 1 = 8.

8. (\subseteq) If xZx \in \mathbb Z and x2=4x^2 = 4 then (x2)(x+2)=0(x-2)(x+2)=0, so x=2x = 2 or x=2x = -2; either way x{2,2}x \in \{-2,2\}. (\supseteq) 22=42^2 = 4 and (2)2=4(-2)^2 = 4 with 2,2Z2, -2 \in \mathbb Z, so both belong to the left set. Hence equality by double inclusion.

9. {3,6,9,12,15}={3kkN, k5}\{3, 6, 9, 12, 15\} = \{\,3k \mid k \in \mathbb N,\ k \le 5\,\}. Recursive definition of all positive multiples of 33: basis 3S3 \in S; rule if nSn \in S then n+3Sn + 3 \in S; (closure).

12. {a,b}×{1,2,3}={(a,1),(a,2),(a,3),(b,1),(b,2),(b,3)}\{a,b\}\times\{1,2,3\} = \{(a,1),(a,2),(a,3),(b,1),(b,2),(b,3)\}; {1,2,3}×{a,b}={(1,a),(1,b),(2,a),(2,b),(3,a),(3,b)}\{1,2,3\}\times\{a,b\} = \{(1,a),(1,b),(2,a),(2,b),(3,a),(3,b)\}. Both have 66 elements, but the products are not equal (e.g. (a,1)(a,1) is in the first, not the second), so ×\times is not commutative.

13. Length 00: ε\varepsilon. Length 22: (). Length 44: (()), ()() — two of them. (Odd lengths are impossible.) The count of balanced strings of length 2n2n is the Catalan number CnC_n; for length 66 (n=3n=3), C3=5C_3 = 5.

14. Each of the 88 elements is independently in or out, giving 28=2562^8 = 256 characteristic vectors, hence 256256 subsets. With bit ii meaning “aiSa_i \in S,” the subset {a0,a3,a7}\{a_0, a_3, a_7\} is the byte 1000100110001001 (bit 77 leftmost) — equivalently value 20+23+27=1372^0 + 2^3 + 2^7 = 137.

15. Mimic Theorem 1.7: assume 3=p/q\sqrt3 = p/q in lowest terms, get p2=3q2p^2 = 3q^2, so 3p23 \mid p^2. Primality of 33 gives 3p3 \mid p (a prime dividing a product divides a factor — Euclid’s lemma; this is the step that needs 33 prime). Write p=3kp = 3k, deduce 3q3 \mid q, contradicting lowest terms. (For a non-square like 33, 66, \dots the argument works; for a perfect square like 44 it correctly fails, since 4=2\sqrt4 = 2 is rational.)

16. Negation of A\varnothing \subseteq A: “x(xxA)\exists x\,(x \in \varnothing \wedge x \notin A).” Such an xx satisfies xx \in \varnothing, impossible. The existence assumption is therefore false, so A\varnothing \subseteq A.

18. List N×N\mathbb N \times \mathbb N by anti-diagonals: (1,1); (1,2),(2,1); (1,3),(2,2),(3,1); (1,1);\ (1,2),(2,1);\ (1,3),(2,2),(3,1);\ \dots, i.e. group pairs by the constant sum i+ji + j; each group is finite, so concatenating them enumerates all pairs — a bijection with N\mathbb N. It fails for (0,1)(0,1) because a real is an infinite sequence of digits, not a finite pair of indices; the diagonal argument (Thm 9.3) shows any purported list is incomplete.

19. 1f(1)={2}1 \notin f(1) = \{2\}, so 1D1 \in D; 2f(2)={1,2,3}2 \in f(2) = \{1,2,3\}, so 2D2 \notin D; 3f(3)=3 \notin f(3) = \varnothing, so 3D3 \in D. Thus D={1,3}D = \{1,3\}. Checking: f(1)={2}f(1) = \{2\}, f(2)={1,2,3}f(2) = \{1,2,3\}, f(3)=f(3) = \varnothing — none equals {1,3}\{1,3\}, so DD is outside the image of ff, confirming ff is not surjective.

20. If RR existed, then RR    RRR \in R \iff R \notin R (substitute RR into the defining property), a contradiction; so RR cannot exist. Separation only lets you form {xUxx}\{x \in U \mid x \notin x\} for an already-existing set UU; the result is a subset of UU and one shows it simply is not an element of UU, producing no contradiction — the self-swallowing “set of all sets” is never available.


Further reading

  • Kenneth H. Rosen, Discrete Mathematics and Its Applications — Chapter 2 (Basic Structures: Sets, Functions, Sequences, Sums, and Matrices) covers sets, the power set, and Cartesian products, and §1.2.5 treats cardinality and Cantor’s diagonal argument.
  • Susanna S. Epp, Discrete Mathematics with Applications — Chapter 6 (Set Theory) develops the element method for proving subset and equality relations in careful detail, closely matching the double-inclusion technique of §1.5.
  • For the axiomatic and historical background (extensionality, separation, Russell’s paradox, ZFC), Paul Halmos’s Naive Set Theory is a classic short treatment.

These texts use N={0,1,2,}\mathbb N = \{0,1,2,\dots\} in places; recall (§1.3) that our course convention is N={1,2,3,}\mathbb N = \{1,2,3,\dots\}.

Lectures/CDM-L01.md · 70.0 KB · updated 2026-08-01 21:11