Skip to content

F1

Sets, families and intersections

This unit gives you the language for one move that appears all over mathematics for AI: defining the smallest set with some property that contains a given set SS, as the intersection of all such sets. Linear algebra uses it for the span, optimisation for the convex hull, probability for the events generated by a random variable. Learn it once here.

Needs: nothing. Used by: LA1 Vector spaces, LA2 Span.

Full explanationWhy set theory, in a course about AI?

Most introductions define the span of vectors v1,…,vnv_1, \dots, v_n as “all vectors of the form a1v1+⋯+anvna_1 v_1 + \dots + a_n v_n”. That works while you have finitely many vectors. Now take infinitely many, say the functions 1,x,x2,x3,…1, x, x^2, x^3, \dots. What is “all combinations” of those? Is 1+x+x2/2+x3/6+⋯1 + x + x^2/2 + x^3/6 + \cdots one of them? A vector space only tells you how to add two vectors, so an infinite sum has no meaning there, and the finite-list definition has nothing to say.

There is a cleaner definition that never mentions sums at all: the span of SS is the intersection of every subspace that contains SS. To read it you need to know what “the intersection of a family of sets” means, including the edge cases (what if the family is empty?). That is what this unit covers, and nothing more. We use naive set theory in the sense of Halmos: sets are collections, and we stay away from the corners where that intuition breaks.

Definition F1.1Set, element#

A set is a collection of objects, its elements. We write x∈Ax \in A for ”xx is an element of AA” and x∉Ax \notin A otherwise. Two sets are equal exactly when they have the same elements.

So {1,2,2}={2,1}\{1, 2, 2\} = \{2, 1\}: order and repetition do not matter, only membership. Sets can contain sets: {∅}\{\varnothing\} is a set with one element, which happens to be the empty set.

Definition F1.2Subset#

AA is a subset of BB, written A⊆BA \subseteq B, if every element of AA is an element of BB.

Theorem F1.3Equality by double inclusion#

A=BA = B if and only if A⊆BA \subseteq B and B⊆AB \subseteq A.

This is how almost every “these two sets are the same” proof goes, including the main theorem of LA2: show each set sits inside the other.

Definition F1.4Empty set, set-builder notation#

The empty set ∅\varnothing is the set with no elements. For a set AA and a property PP, the set {x∈A:P(x)}\{x \in A : P(x)\} contains exactly the elements of AA that have property PP.

Theorem F1.5The empty set is a subset of everything#

For every set AA, ∅⊆A\varnothing \subseteq A.

Proofof F1.5

We must show: every element of ∅\varnothing is an element of AA. There are no elements of ∅\varnothing, so there is nothing to check, and the statement is true. A claim of the form “every element of an empty collection has property PP” is called vacuously true.

Full explanationVacuous truth, and why set-builder notation always says “x ∈ A”

Vacuous truth feels like a trick, but it is forced on us. “Every element of ∅\varnothing is in AA” can only be false if some element of ∅\varnothing is not in AA, and there is no element to be the counterexample. Hold on to this: in the next section, the same reasoning makes the intersection of an empty family behave strangely.

Notice also that set-builder notation selects elements from an existing set AA. The unrestricted version {x:P(x)}\{x : P(x)\} is not allowed, because some properties define something that cannot be a set. Russell’s example is {x:x∉x}\{x : x \notin x\}, the collection of all sets that are not members of themselves. Ask whether it is a member of itself: if it is, it isn’t; if it isn’t, it is. Selecting from a set you already have avoids that. It matters to us for one reason only: “the set of everything” is not a set. If some set UU contained everything, then {x∈U:x∉x}\{x \in U : x \notin x\} would be a legal selection from UU, and it would be Russell’s paradoxical collection. So no such UU exists.

Convention F1.6Number sets used on this site#

N={0,1,2,… }\mathbb{N} = \{0, 1, 2, \dots\}, Z\mathbb{Z} the integers, Q\mathbb{Q} the rationals, R\mathbb{R} the reals, C\mathbb{C} the complex numbers. ":=:=" means “is defined as”.

Check Is ∅ an element of {∅}? Is ∅ a subset of {∅}? Is {∅} equal to ∅?

Yes, ∅∈{∅}\varnothing \in \{\varnothing\}: it is the one element listed. Yes, ∅⊆{∅}\varnothing \subseteq \{\varnothing\}, as it is a subset of every set (F1.5). No, {∅}≠∅\{\varnothing\} \neq \varnothing: the left side has one element, the right side none.

Definition F1.7Union, intersection, difference#

A∪B:={x:x∈A or x∈B}A \cup B := \{x : x \in A \text{ or } x \in B\}, A∩B:={x∈A:x∈B}\quad A \cap B := \{x \in A : x \in B\}, A∖B:={x∈A:x∉B}\quad A \setminus B := \{x \in A : x \notin B\}.

Intersections and differences are selections from AA, as F1.4 requires. Unions are not carved out of an existing set: that A∪BA \cup B exists is a separate basic principle of set theory (the axiom of union), which we take for granted.

Definition F1.8Cartesian product#

A×BA \times B is the set of ordered pairs (a,b)(a, b) with a∈Aa \in A and b∈Bb \in B, where (a,b)=(a′,b′)(a, b) = (a', b') exactly when a=a′a = a' and b=b′b = b'. More generally An=A×⋯×AA^n = A \times \cdots \times A is the set of ordered nn-tuples.

Unlike sets, pairs care about order: (1,2)≠(2,1)(1, 2) \neq (2, 1). You need products for two reasons. Rn\mathbb{R}^n is literally the set of nn-tuples of reals. And the operations of a vector space are functions of two inputs: addition takes a pair of vectors, V×V→VV \times V \to V (LA1.3).

Definition F1.9Function#

A function f:A→Bf : A \to B assigns to every a∈Aa \in A exactly one element f(a)∈Bf(a) \in B. AA is the domain, BB the codomain. The set of all functions from AA to BB is written BAB^A.

Full explanationA vector is a function

The notation BAB^A is not a coincidence. A vector x=(x1,…,xn)∈Rnx = (x_1, \dots, x_n) \in \mathbb{R}^n is exactly a function from the index set {1,…,n}\{1, \dots, n\} to R\mathbb{R}: index ii goes to xix_i. So Rn\mathbb{R}^n and R{1,…,n}\mathbb{R}^{\{1, \dots, n\}} are the same thing written two ways.

Push the idea and many objects line up:

ObjectIndex set XXAs a function X→RX \to \mathbb{R}
vector in Rn\mathbb{R}^n{1,…,n}\{1, \dots, n\}i↦xii \mapsto x_i
m×nm \times n matrix{1,…,m}×{1,…,n}\{1, \dots, m\} \times \{1, \dots, n\}(i,j)↦aij(i, j) \mapsto a_{ij}
greyscale image, H×WH \times W pixelspixel gridpixel ↦\mapsto intensity
infinite sequenceN\mathbb{N}k↦xkk \mapsto x_k
real functionR\mathbb{R}t↦f(t)t \mapsto f(t)

In LA1 this turns into one theorem: all of these are vector spaces for the same reason.

Definition F1.10Support, finitely supported#

For a function c:A→Rc : A \to \mathbb{R} (or into any number system with a zero), its support is supp⁡c:={a∈A:c(a)≠0}\operatorname{supp} c := \{a \in A : c(a) \neq 0\}. The function is finitely supported if its support is a finite set.

A finitely supported function can live on an enormous, even uncountable, domain, yet be non-zero in only finitely many places. That is exactly the bookkeeping needed for linear combinations of infinitely many vectors (LA2.2).

Definition F1.11Family of sets#

A family of sets is a set whose elements are themselves sets. We write families with script letters, A\mathcal{A}. An indexed family (Ai)i∈I(A_i)_{i \in I} assigns a set AiA_i to each index ii in an index set II.

Definition F1.12Union and intersection of a family#

For a family A\mathcal{A},

⋃A:={x:x∈A for some A∈A},⋂A:={x:x∈A for every A∈A}.\bigcup \mathcal{A} := \{x : x \in A \text{ for some } A \in \mathcal{A}\}, \qquad \bigcap \mathcal{A} := \{x : x \in A \text{ for every } A \in \mathcal{A}\}.

The intersection is only defined when A\mathcal{A} is non-empty. For an indexed family, ⋃i∈IAi\bigcup_{i \in I} A_i and ⋂i∈IAi\bigcap_{i \in I} A_i mean the same with AA ranging over the AiA_i; the intersection requires I≠∅I \neq \varnothing.

Full explanationWhy the intersection needs a non-empty family

Try A=∅\mathcal{A} = \varnothing. Which xx satisfy ”x∈Ax \in A for every A∈AA \in \mathcal{A}”? There is no AA to check, so the condition is vacuously true for every object whatsoever. The empty intersection would be “the set of everything”, which we saw is not a set. Halmos puts it bluntly: an empty intersection does not make sense.

The non-empty case is safe. Pick any A0∈AA_0 \in \mathcal{A}; every element of the intersection is in particular in A0A_0, so

⋂A={x∈A0:x∈A for every A∈A},\bigcap \mathcal{A} = \{x \in A_0 : x \in A \text{ for every } A \in \mathcal{A}\},

an honest set-builder selection from the existing set A0A_0. The answer does not depend on which A0A_0 you pick.

When all sets in a family are subsets of one fixed ambient set XX, some books define the empty intersection to be XX itself. That is a convention, and you will rarely need it here: every intersection we take, like “all subspaces of VV that contain SS”, has at least one member (VV itself), so it is never empty.

Example F1.13Infinite intersections can be surprising#

For n=1,2,3,…n = 1, 2, 3, \dots let An=[−1n,1n]A_n = [-\tfrac{1}{n}, \tfrac{1}{n}] and Bn=(0,1n)B_n = (0, \tfrac{1}{n}). Then

⋂n≥1An={0},⋂n≥1Bn=∅,⋃n≥1An=[−1,1].\bigcap_{n \ge 1} A_n = \{0\}, \qquad \bigcap_{n \ge 1} B_n = \varnothing, \qquad \bigcup_{n \ge 1} A_n = [-1, 1].

Every BnB_n is non-empty, and each contains the next, yet nothing lies in all of them. If x≤0x \le 0, then x∉B1x \notin B_1. If x>0x > 0, some 1n\tfrac{1}{n} is smaller than xx (the Archimedean property of the reals), so x∉Bnx \notin B_n.

Theorem F1.14The intersection is the largest common subset#

Let A\mathcal{A} be a non-empty family.

  1. ⋂A⊆A\bigcap \mathcal{A} \subseteq A for every A∈AA \in \mathcal{A}.
  2. If a set CC satisfies C⊆AC \subseteq A for every A∈AA \in \mathcal{A}, then C⊆⋂AC \subseteq \bigcap \mathcal{A}.
Proofof F1.14

(1) Take x∈⋂Ax \in \bigcap \mathcal{A}. By definition xx is in every member of A\mathcal{A}, in particular in AA.

(2) Take x∈Cx \in C. For each A∈AA \in \mathcal{A} we have C⊆AC \subseteq A, so x∈Ax \in A. Hence xx is in every member of A\mathcal{A}, which means x∈⋂Ax \in \bigcap \mathcal{A}.

This is the payoff of the unit. Suppose you have a kind of “nice” subset (subspaces, convex sets, closed sets) and a set SS that is not nice. Is there a smallest nice set containing SS?

Theorem F1.15Closure under intersection gives a smallest member#

Let XX be a set and C\mathcal{C} a family of subsets of XX such that

  • X∈CX \in \mathcal{C}, and
  • the intersection of every non-empty subfamily of C\mathcal{C} belongs to C\mathcal{C}.

For S⊆XS \subseteq X define ⟨S⟩:=⋂{C∈C:S⊆C}\langle S \rangle := \bigcap \{C \in \mathcal{C} : S \subseteq C\}. Then ⟨S⟩∈C\langle S \rangle \in \mathcal{C}, S⊆⟨S⟩S \subseteq \langle S \rangle, and ⟨S⟩⊆C\langle S \rangle \subseteq C for every C∈CC \in \mathcal{C} with S⊆CS \subseteq C. In words: ⟨S⟩\langle S \rangle is the smallest member of C\mathcal{C} containing SS.

Proofof F1.15

Let F={C∈C:S⊆C}\mathcal{F} = \{C \in \mathcal{C} : S \subseteq C\}. It is non-empty, because X∈CX \in \mathcal{C} and S⊆XS \subseteq X, so the intersection is defined.

  • F\mathcal{F} is a non-empty subfamily of C\mathcal{C}, so by assumption ⟨S⟩=⋂F∈C\langle S \rangle = \bigcap \mathcal{F} \in \mathcal{C}.
  • Every member of F\mathcal{F} contains SS, so F1.14(2), applied to the set SS, gives S⊆⟨S⟩S \subseteq \langle S \rangle.
  • If C∈CC \in \mathcal{C} and S⊆CS \subseteq C, then C∈FC \in \mathcal{F}, and F1.14(1) gives ⟨S⟩⊆C\langle S \rangle \subseteq C.
Full explanationWhat “smallest” means, and why the two conditions matter

“Smallest” means smallest for ⊆\subseteq: contained in every competitor. That is stronger than “has the fewest elements” and it need not exist. Take X={1,2,3}X = \{1, 2, 3\} and let C\mathcal{C} be the subsets with exactly two elements. For S={1}S = \{1\}, both {1,2}\{1, 2\} and {1,3}\{1, 3\} contain SS, but neither is inside the other, and their intersection {1}\{1\} is not in C\mathcal{C}. No smallest member exists, because C\mathcal{C} is not closed under intersection.

The condition X∈CX \in \mathcal{C} is what keeps the family F\mathcal{F} non-empty. Without it, there may be no member containing SS at all.

The same theorem, with different families C\mathcal{C}, produces many objects you will meet:

Family C\mathcal{C}⟨S⟩\langle S \rangle is calledUsed in
subspaces of a vector spacethe span of SSlinear algebra, everywhere
convex subsets of Rn\mathbb{R}^nthe convex hulloptimisation, attention outputs
closed subsets of Rn\mathbb{R}^nthe closurelimits, approximation
σ-algebras on a setthe generated σ-algebraprobability: the events you can observe

Each one needs its own check of both conditions: C\mathcal{C} is closed under non-empty intersections and contains XX. For subspaces, that check is LA1.14.

Check Let C be the family of all finite subsets of ℕ. It is closed under intersections of non-empty subfamilies. Does every S ⊆ ℕ have a smallest finite superset?

No. The second condition holds (an intersection is inside one of its finite members, so it is finite), but the first fails: N\mathbb{N} itself is not finite, so N∉C\mathbb{N} \notin \mathcal{C}. For infinite SS, such as the even numbers, no finite set contains SS at all, so the family F\mathcal{F} in F1.15 is empty and there is nothing to intersect.

Check Why is “the intersection of all subspaces of V that contain S” never an empty intersection?

Because VV is itself a subspace of VV and contains SS, so the family always has at least one member.

Check Is the union of two subsets in C always in C? Think of two lines through the origin in ℝ², with C the subspaces.

No. The xx-axis and the yy-axis are subspaces, but their union is not: (1,0)+(0,1)=(1,1)(1, 0) + (0, 1) = (1, 1) is in neither line. Intersections preserve “niceness”; unions usually don’t. That is why the span is defined by intersecting.

  • Paul R. Halmos, Naive Set Theory (1960): sets, families, unions and intersections; the remark that an empty intersection does not make sense.
  • ProofWiki, Intersection of Empty Set: how different authors handle the empty intersection.