Set theory provides a common language for modern mathematics. Many mathematical objects can be described as sets with additional structure, and many mathematical constructions can be described using membership, subsets, relations, and functions. In this section we introduce these basic notions carefully, since later parts of logic and foundations use them constantly.
Sets and Membership
A set is a collection of objects, called its elements or members. If an object a is an element of a set A, we write:
a∈AIf a is not an element of A, we write:
a∈/AThe relation ∈ is called membership. It is the most basic relation in set theory. The expression a∈A is a statement, and it says that the object a belongs to the set A.
For example, if:
A={1,2,3}then:
1∈Aand:
4∈/AA set is determined by its elements. This means that two sets are equal exactly when they have the same elements.
Definition 7.1 (Equality of Sets)
Two sets A and B are equal if and only if every object belongs to A exactly when it belongs to B:
A=Bif and only if∀x(x∈A↔x∈B)This principle is often called extensionality. It says that a set has no hidden structure beyond its elements. If two sets contain the same elements, then they are the same set.
Example 7.2
The sets:
{1,2,3}and:
{3,2,1}are equal, because they have exactly the same elements.
Also:
{1,1,2,3}={1,2,3}because repetition does not create new elements.
Thus order and repetition do not matter for sets.
Definition 7.3 (Subset)
Let A and B be sets. We write:
A⊆Bif:
∀x(x∈A→x∈B)In words, A⊆B means that every element of A is also an element of B.
If:
A⊆Band:
A=Bthen A is called a proper subset of B.
Example 7.4
Let:
A={1,2}and:
B={1,2,3}Then:
A⊆Bbecause every element of A is also an element of B.
But:
B⊈Abecause:
3∈Band:
3∈/ALemma 7.5 (Set Equality by Double Inclusion)
For any sets A and B:
A=Bif and only if:
A⊆BandB⊆AProof
Suppose first that A=B. Then every element of A is an element of B, and every element of B is an element of A, because the two sets are the same set. Hence:
A⊆Band:
B⊆AConversely, suppose that:
A⊆BandB⊆ALet x be any object. If x∈A, then x∈B because A⊆B. If x∈B, then x∈A because B⊆A. Therefore:
x∈A↔x∈Bfor every object x. By extensionality:
A=BDefinition 7.6 (Empty Set)
The empty set is the set with no elements. It is denoted by:
∅A set E is empty if:
∀x(x∈/E)The empty set is the unique set with this property.
Lemma 7.7 (Uniqueness of the Empty Set)
If E and F are empty sets, then:
E=FProof
Assume that E and F are empty sets. To show E=F, it is enough to show double inclusion.
First, let x∈E. Since E is empty, this is impossible. Therefore the implication:
x∈E→x∈Fis true for every x, and hence:
E⊆FThe same argument shows:
F⊆EBy Lemma 7.5:
E=FLemma 7.8 (Empty Set Is a Subset of Every Set)
For every set A:
∅⊆AProof
We must show:
∀x(x∈∅→x∈A)Let x be arbitrary. The statement x∈∅ is false by definition of the empty set. Therefore:
x∈∅→x∈Ais true. Since x was arbitrary:
∅⊆ADefinition 7.9 (Union)
The union of A and B is the set:
A∪B={x:x∈A or x∈B}Thus:
x∈A∪Bif and only ifx∈A∨x∈BThe union contains everything that belongs to at least one of the two sets.
Definition 7.10 (Intersection)
The intersection of A and B is the set:
A∩B={x:x∈A and x∈B}Thus:
x∈A∩Bif and only ifx∈A∧x∈BThe intersection contains exactly the elements common to both sets.
Definition 7.11 (Difference)
The difference of A and B is the set:
A∖B={x:x∈A and x∈/B}Thus:
x∈A∖Bif and only ifx∈A∧x∈/BThe difference consists of the elements of A that are not in B.
Example 7.12
Let:
A={1,2,3}and:
B={3,4,5}Then:
A∪B={1,2,3,4,5}A∩B={3}A∖B={1,2}B∖A={4,5}Lemma 7.13 (Commutativity of Union and Intersection)
For all sets A and B:
A∪B=B∪Aand:
A∩B=B∩AProof
We prove the statement for union first. Let x be arbitrary. Then:
x∈A∪Bif and only if:
x∈A∨x∈Bwhich is equivalent to:
x∈B∨x∈Awhich is equivalent to:
x∈B∪ATherefore:
A∪B=B∪AThe proof for intersection is similar. We have:
x∈A∩Bif and only if:
x∈A∧x∈Bwhich is equivalent to:
x∈B∧x∈Awhich is equivalent to:
x∈B∩ATherefore:
A∩B=B∩ALemma 7.14 (Associativity of Union and Intersection)
For all sets A, B, and C:
(A∪B)∪C=A∪(B∪C)and:
(A∩B)∩C=A∩(B∩C)Proof
We prove the statement for union. Let x be arbitrary. Then:
x∈(A∪B)∪Cif and only if:
x∈A∪B∨x∈Cif and only if:
(x∈A∨x∈B)∨x∈Cif and only if:
x∈A∨(x∈B∨x∈C)if and only if:
x∈A∨x∈B∪Cif and only if:
x∈A∪(B∪C)By extensionality:
(A∪B)∪C=A∪(B∪C)The proof for intersection is the same with “or” replaced by “and”. For every x:
x∈(A∩B)∩Cif and only if:
(x∈A∧x∈B)∧x∈Cif and only if:
x∈A∧(x∈B∧x∈C)if and only if:
x∈A∩(B∩C)Thus:
(A∩B)∩C=A∩(B∩C)Lemma 7.15 (Distributive Laws)
For all sets A, B, and C:
A∩(B∪C)=(A∩B)∪(A∩C)and:
A∪(B∩C)=(A∪B)∩(A∪C)Proof
We prove the first identity. Let x be arbitrary. Then:
x∈A∩(B∪C)if and only if:
x∈A∧x∈B∪Cif and only if:
x∈A∧(x∈B∨x∈C)if and only if:
(x∈A∧x∈B)∨(x∈A∧x∈C)if and only if:
x∈A∩B∨x∈A∩Cif and only if:
x∈(A∩B)∪(A∩C)Therefore:
A∩(B∪C)=(A∩B)∪(A∩C)The second identity is proved similarly. For every x:
x∈A∪(B∩C)if and only if:
x∈A∨(x∈B∧x∈C)if and only if:
(x∈A∨x∈B)∧(x∈A∨x∈C)if and only if:
x∈(A∪B)∩(A∪C)Thus:
A∪(B∩C)=(A∪B)∩(A∪C)Definition 7.16 (Power Set)
The power set of A is:
P(A)={X:X⊆A}Thus:
X∈P(A)if and only ifX⊆AExample 7.17
If:
A={1,2}then:
P(A)={∅,{1},{2},{1,2}}The power set contains sets as elements. The elements of P(A) are subsets of A, not usually elements of A.
Definition 7.18 (Ordered Pair)
An ordered pair is written:
(a,b)and is characterized by the property:
(a,b)=(c,d)if and only ifa=c and b=dThis property is the essential feature of ordered pairs.
Definition 7.19 (Cartesian Product)
The Cartesian product of sets A and B is:
A×B={(a,b):a∈A and b∈B}Thus an element of A×B is an ordered pair whose first coordinate belongs to A and whose second coordinate belongs to B.
Example 7.20
If:
A={1,2}and:
B={x,y}then:
A×B={(1,x),(1,y),(2,x),(2,y)}In general, A×B and B×A are different, because ordered pairs remember which coordinate comes first.
Definition 7.21 (Relation)
A relation from A to B is a subset:
R⊆A×BIf A=B, then a relation from A to A is called a relation on A.
If:
(a,b)∈Rwe often write:
aRbA relation records which elements are related to which other elements.
Example 7.22
Let:
A={1,2,3}Define a relation R on A by:
aRbif and only ifa<bThen:
R={(1,2),(1,3),(2,3)}The pair (2,1) is not in R, because 2<1 is false.
Properties of Relations
Let R be a relation on a set A.
The relation R is reflexive if:
∀a∈A, aRaIt is symmetric if:
∀a,b∈A, aRb→bRaIt is transitive if:
∀a,b,c∈A, (aRb∧bRc)→aRcIt is antisymmetric if:
∀a,b∈A, (aRb∧bRa)→a=bThese properties are used to define important classes of relations, especially equivalence relations and order relations.
Definition 7.23 (Equivalence Relation)
A relation R on a set A is an equivalence relation if it is reflexive, symmetric, and transitive.
Equivalence relations formalize the idea of treating objects as the same according to some chosen criterion.
Example 7.24
On the set of integers Z, define:
aRbif and only ifa−b is evenThis relation means that a and b have the same parity.
It is reflexive because:
a−a=0is even.
It is symmetric because if a−b is even, then:
b−a=−(a−b)is also even.
It is transitive because if a−b is even and b−c is even, then:
a−c=(a−b)+(b−c)is even.
Therefore R is an equivalence relation.
Definition 7.25 (Equivalence Class)
Let R be an equivalence relation on A, and let a∈A. The equivalence class of a is:
[a]={x∈A:xRa}The equivalence class of a consists of all elements equivalent to $a`.
Lemma 7.26 (Equivalence Classes Are Equal or Disjoint)
Let R be an equivalence relation on A. For any a,b∈A, either:
[a]=[b]or:
[a]∩[b]=∅Proof
Suppose:
[a]∩[b]=∅Then there exists an element x such that:
x∈[a]∩[b]Thus:
xRaand:
xRbSince R is symmetric, from xRa we get:
aRxSince aRx and xRb, transitivity gives:
aRbWe show that [a]⊆[b]. Let y∈[a]. Then:
yRaSince aRb, transitivity gives:
yRbTherefore:
y∈[b]So:
[a]⊆[b]Similarly, since aRb, symmetry gives:
bRaThe same argument shows:
[b]⊆[a]Hence:
[a]=[b]Therefore, if two equivalence classes meet, they are equal. If they do not meet, they are disjoint.
Definition 7.27 (Partial Order)
A relation ≤ on a set A is a partial order if it is reflexive, antisymmetric, and transitive.
That is, for all a,b,c∈A:
a≤a(a≤b∧b≤a)→a=b(a≤b∧b≤c)→a≤cA set together with a partial order is called a partially ordered set, or poset.
Example 7.28
Let A be any set. The subset relation:
⊆is a partial order on P(A).
It is reflexive because:
X⊆Xfor every X⊆A.
It is antisymmetric because:
X⊆YandY⊆Ximply:
X=YIt is transitive because:
X⊆YandY⊆Zimply:
X⊆ZDefinition 7.29 (Linear Order)
A partial order ≤ on A is a linear order if every two elements are comparable:
∀a,b∈A, a≤b∨b≤aLinear orders are also called total orders.
Example 7.30
The usual order on the natural numbers:
≤is a linear order, because any two natural numbers can be compared.
The subset order on a power set is usually not a linear order. For example, if:
A={1,2}then:
{1}⊈{2}and:
{2}⊈{1}Thus {1} and {2} are not comparable under ⊆.
Definition 7.31 (Function)
A function from A to B is a relation:
f⊆A×Bsuch that for every a∈A, there exists a unique b∈B with:
(a,b)∈fWe write:
f:A→Band we write:
f(a)=bwhen:
(a,b)∈fThe set A is called the domain of f, and the set B is called the codomain of f.
Example 7.32
Let:
A={1,2,3}and:
B={a,b}The relation:
f={(1,a),(2,a),(3,b)}is a function from A to B, because every element of A appears exactly once as a first coordinate.
The relation:
g={(1,a),(1,b),(2,a)}is not a function from A to B, because 1 has two outputs and 3 has no output.
Definition 7.33 (Image and Preimage)
Let:
f:A→BIf X⊆A, the image of X under f is:
f[X]={f(x):x∈X}If Y⊆B, the preimage of Y under f is:
f−1[Y]={x∈A:f(x)∈Y}The image moves subsets of the domain forward into the codomain. The preimage moves subsets of the codomain backward into the domain.
Lemma 7.34 (Basic Image Properties)
Let f:A→B, and let X,Y⊆A. Then:
f[X∪Y]=f[X]∪f[Y]Also:
f[X∩Y]⊆f[X]∩f[Y]Proof
First we prove:
f[X∪Y]=f[X]∪f[Y]Let b∈f[X∪Y]. Then there exists a∈X∪Y such that:
f(a)=bSince a∈X∪Y, either a∈X or a∈Y. If a∈X, then b∈f[X]. If a∈Y, then b∈f[Y]. Hence:
b∈f[X]∪f[Y]Thus:
f[X∪Y]⊆f[X]∪f[Y]Conversely, let b∈f[X]∪f[Y]. Then either b∈f[X] or b∈f[Y].
If b∈f[X], then there exists a∈X such that f(a)=b. Since X⊆X∪Y, we have a∈X∪Y, so b∈f[X∪Y].
If b∈f[Y], the same argument shows b∈f[X∪Y].
Therefore:
f[X]∪f[Y]⊆f[X∪Y]By double inclusion:
f[X∪Y]=f[X]∪f[Y]Now we prove:
f[X∩Y]⊆f[X]∩f[Y]Let b∈f[X∩Y]. Then there exists a∈X∩Y such that:
f(a)=bSince a∈X∩Y, we have a∈X and a∈Y. Therefore b∈f[X] and b∈f[Y]. Hence:
b∈f[X]∩f[Y]So:
f[X∩Y]⊆f[X]∩f[Y]The reverse inclusion does not hold for arbitrary functions, because two different elements may have the same image.
Definition 7.35 (Injective, Surjective, Bijective)
Let:
f:A→BThe function f is injective if distinct inputs have distinct outputs:
∀x,y∈A, f(x)=f(y)→x=yThe function f is surjective if every element of the codomain is hit by the function:
∀b∈B, ∃a∈A, f(a)=bThe function f is bijective if it is both injective and surjective.
Injective functions are also called one to one functions. Surjective functions are also called onto functions.
Example 7.36
The function:
f:Z→Zdefined by:
f(n)=n+1is bijective.
It is injective because if:
n+1=m+1then:
n=mIt is surjective because for every k∈Z, the integer:
k−1satisfies:
f(k−1)=kThe function:
g:N→Ndefined by:
g(n)=n+1is injective but not surjective if 0∈N, because no natural number maps to 0.
Lemma 7.37 (Inverse of a Bijection)
Let:
f:A→Bbe a bijection. Then there exists a unique function:
f−1:B→Asuch that:
f−1(f(a))=afor all a∈A, and:
f(f−1(b))=bfor all b∈B.
Proof
Since f is surjective, for every b∈B there exists at least one a∈A such that:
f(a)=bSince f is injective, this element a is unique. Indeed, if:
f(a)=band:
f(a′)=bthen:
f(a)=f(a′)and injectivity gives:
a=a′Therefore, for each b∈B, there is a unique a∈A satisfying f(a)=b. Define:
f−1(b)=awhere a is this unique element.
This defines a function:
f−1:B→ABy construction, if b=f(a), then the unique element mapping to b is a, so:
f−1(f(a))=aAlso, for any b∈B, the definition of f−1(b) gives:
f(f−1(b))=bUniqueness follows because any function satisfying these two identities must send each b∈B to the unique element of A that maps to b under f.
Definition 7.38 (Composition)
Let:
f:A→Band:
g:B→CThe composition of g with f is the function:
g∘f:A→Cdefined by:
(g∘f)(a)=g(f(a))for all a∈A.
The function f is applied first, and then g is applied.
Lemma 7.39 (Associativity of Composition)
Let:
f:A→Bg:B→Ch:C→DThen:
h∘(g∘f)=(h∘g)∘fProof
To prove equality of functions, it is enough to show that they have the same value at every input.
Let a∈A. Then:
(h∘(g∘f))(a)=h((g∘f)(a))By definition of composition:
h((g∘f)(a))=h(g(f(a)))On the other hand:
((h∘g)∘f)(a)=(h∘g)(f(a))Again by definition of composition:
(h∘g)(f(a))=h(g(f(a)))Thus:
(h∘(g∘f))(a)=((h∘g)∘f)(a)for every a∈A. Therefore:
h∘(g∘f)=(h∘g)∘fDefinition 7.40 (Identity Function)
For a set A, the identity function on A is:
idA:A→Adefined by:
idA(a)=afor all a∈A.
Lemma 7.41 (Identity Laws)
Let:
f:A→BThen:
f∘idA=fand:
idB∘f=fProof
Let a∈A. Then:
(f∘idA)(a)=f(idA(a))=f(a)Thus:
f∘idA=fAlso:
(idB∘f)(a)=idB(f(a))=f(a)Thus:
idB∘f=f