Professional Documents
Culture Documents
Set Theory
Set theory is one of the most fundamental branches of mathematics. Many
profound advances in mathematics over the past century have taken place in
set theory, and there is a deep connection between set theory and logic. More
importantly for computer science, it has turned out that the notation and
terminology
of elementary set theory is extremely useful for describing algorithms,
and nearly every branch of computing uses sets from time to time.
This chapter introduces the concepts from set theory that you will need for
computer science. Section 8.1 begins by describing what sets are and giving
several notations for describing them. There are many useful operations that
can be performed on sets, and these are presented in Section 8.2. In Section
8.3, we consider a particular kind of set that is well suited for computing
applications: the finite sets with equality. Next, in Section 8.4 we study a
variety of mathematical laws that describe properties of sets that are useful in
computing. The chapter concludes with a summary of the notations and the
main theorems of set theory.
8.1 Notations for Describing Sets
We will not define formally what a set is. The reason for this is that set
theory was intended originally to serve as the foundation for all of mathematics:
everything else in mathematics is to be defined—at least in principle—in terms
of sets. As sets are the lowest level concept, there is nothing more primitive
that could be used to define them formally.
Informally, a set is just a collection of objects called members or elements.
You can think of a set as a group of members, or a collection, or a class,
etc. However, these words are just synonyms—they don’t constitute a precise
definition of a set. One way to describe a set is to write down all its members
inside braces { }. Here are some examples:
A = {dog, cat, horse}
B = {canary, eagle}
C = {0, 1, 2, 3, 4}
D = {0, 1, . . . , 100}
E={}
N = {0, 1, 2, 3, . . .}
Z = {3, {dog, 7}, horse}
Any particular thing can appear only once in a set; this means that it makes
sense to ask whether x is a member of a set S—the answer must be yes or no—
but it doesn’t make sense to ask how many times x occurs in S. It is bad
notation to write a set with some element appearing several times, because the
extra occurrences of the element are meaningless, and they might be confusing.
You can always remove the redundant copies of an element without changing
the set.
A set can have any number of elements. For example, A has three elements,
E has zero elements, and N has an infinite number of elements.
It is common to use lower-case letters (a, b, . . .) to refer to members of a set
and to use upper-case letters (A,B, . . .) as names for sets themselves. This is
just a convention, not an ironclad rule, and of course it breaks down when one
set is a member of another set.
An important special case is the empty set { }. Often the special symbol ∅
is used to denote the empty set.
Suppose we are given some value x and a set S, and we want to know
whether x is a member of S. There is a notation for this question: the expression
x ∈ S is true if x is a member of S and otherwise false. The expression
x ∈ S is pronounced as ‘x is a member of S’, or ‘x is an element of S’, or simply
as ‘x is in S’. For example:
dog ∈ A = True
bat ∈ A = False
Another useful notation is x _∈ S, which is True if and only if x ∈ S is False:
dog _∈ A = False
bat _∈ A = True
When a set has a few elements, you can just write them out inside braces.
This is how the sets A, B, and C were defined above. However, when a set has
many elements this becomes tedious, and if the set has an infinite number of
elements it is impossible. The set D has 101 elements, but it is more readable
to use the . . . notation and omit most of them. Set N, the natural numbers,
has an infinite number of elements, and we cannot write them all inside braces.
and
, are larger versions of the ordinary ∪ and ∩ operators.
Definition 22. Let C be a non-empty collection (set) of subsets of the universe
U. Let I be a non-empty set, and for each i ∈ I let Ai ⊆ C. Then
_
i∈I
Ai = {x | ∃i ∈ I . x ∈ Ai},
_
i∈I
Ai = {x | ∀i ∈ I . x ∈ Ai}.
Another way to say this is that if C is a set containing some sets, then the
set of all elements of the sets in C is
A∈C A.
_
A∈C
A = {x | ∃A ∈ C . x ∈ A}
_
A∈C
A = {x | ∀A ∈ C . x ∈ A}
Two sets are disjoint if they have no elements in common.
Definition 23. For any two sets A and B, if A ∩ B = ∅ then A and B are
disjoint sets.
Exercise 1. Given the sets A = {1, 2, 3, 4, 5} and B = {2, 4, 6}, calculate the
following sets:
(a) A ∪ (B ∩ A)
(b) (A ∩ B) ∪ B
(c) A − B
(d) (B − A) ∩ B
(e) A ∪ (B − A)
8.2.3 Complement and Power
In many applications, there is a universe of all the objects that might possibly
appear in any of our sets. For example, we might be working with various sets
of numbers, but none of the sets will contain anything that is not a number.
In this kind of situation, it is often convenient to define the universe explicitly
as a set U, which can then be used in set expressions.