Discrete Structures Set Theory: Duy Bui
Discrete Structures Set Theory: Duy Bui
Duy Bui
This work is produced by The Connexions Project and licensed under the
Creative Commons Attribution License †
1 Set Theory
1.1 Basics
The concept of set is fundamental to mathematics and computer science. Everything mathematical starts
with sets. For example, relationships between two objects are represented as a set of ordered pairs of objects,
the concept of ordered pair is dened using sets, natural numbers, which are the basis of other numbers, are
also dened using sets, the concept of function, being a special type of relation, is based on sets, and graphs
and digraphs consisting of lines and points are described as an ordered pair of sets. Though the concept of
set is fundamental to mathematics, it is not dened rigorously here. Instead we rely on everyone's notion of
"set" as a collection of objects or a container of objects. In that sense "set" is an undened concept here.
Similarly we say an object "belongs to" or "is a member of" a set without rigorously dening what it means.
"An object (element) x belongs to a set A" is symbolically represented by "x ∈ A". It is also assumed that
sets have certain (obvious) properties usually associated with a collection of objects such as the union of sets
exists, for any pair of sets there is a set that contains them etc.
This approach to set theory is called "naive set theory" as opposed to more rigorous "axiomatic set
theory". It was rst developed by the German mathematician Georg Cantor at the end of the 19th century.
Though the naive set theory is not rigorous, it is simpler and practically all the results we need can be
derived within the naive set theory. Thus we shall be following this naive set theory in this course.
A set can be described in a number of dierent ways. The simplest is to list up all of its members if that
is possible. For example {1, 2, 3} is the set of three numbers 1, 2, and 3. { indicates the beginning of the
set, and } its end. Every object between them separated by commas is a member of the set. Thus {{1, 2},
{{3}, 2}, 2}, {1 } } is the set of the elements {1, 2}, {{3}, 2} and {1}.
A set can also be described by listing the properties that its members must satisfy. For example, { x| 1
≤x ≤2 and x is a real number. } represents the set of real numbers between 1 and 2, and { x| x is the square
of an integer and x ≤100 } represents the set { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 }.
A third way to describe a set is to give a procedure to generate the members of the set. The recur-
sive/inductive denition is an example and it is going to be studied later. In this representation, rst, basic
elements of the set are presented. Then a method is given to generate elements of the set from known
elements of the set. Thirdly a statement is given that excludes undesirable elements (which may be included
∗ Version 1.1: Jan 22, 2008 10:27 pm -0600
† http://creativecommons.org/licenses/by/2.0/
http://cnx.org/content/m15772/1.1/
Connexions module: m15772 2
in the set otherwise) from the set. For example the set of natural numbers N can be dened recursively as
the set that satises the following (1), (2), and (3):
(1) 0 ∈ N
(2) For any number x if x ∈N, then x + 1 ∈N.
(3) Nothing is in N unless it is obtained from (1) and (2).
Following this denition, the set of natural numbers N can be obtained as follows: First by (1), 0 is put
into N.
Then by (2), since 0 is in N, 0 + 1 (= 1) is in N.
Then by (2) again, 1 + 1 (= 2) is in N.
Proceeding in this manner all the natural numbers are put into N. Note that if we don't have (3), 0.5,
1.5, 2.5, ... can be included in N, which is not what we want as the set of natural numbers.
Denition (Equality of sets): Two sets are equal if and only if they have the same elements.
More formally, for any sets A and B, A = B if and only if ∀x [ x ∈A ↔ x ∈B ] .
Thus for example {1, 2, 3} = {3, 2, 1}, that is the order of elements does not matter, and {1, 2, 3} =
{3, 2, 1, 1}, that is duplications do not make any dierence for sets.
Denition (Subset): A set A is a subset of a set B if and only if everything in A is also in B.
More formally, for any sets A and B, A is a subset of B, and denoted by A ⊆B, if and only if ∀x [ x∈A
→ x ∈B ] .
If A ⊆B, and A 6=B, then A is said to be a proper subset of B and it is denoted by A⊂B.
For example {1, 2} ⊆ {3, 2, 1}.
Also {1, 2} ⊂ {3, 2, 1}.
Denition (Cardinality): If a set S has n distinct elements for some natural number n, n is the cardinality
(size) of S and S is a nite set. The cardinality of S is denoted by |S|. For example the cardinality of the set
{3, 1, 2} is 3.
Denition (Empty set): A set which has no elements is called an empty set. More formally, an empty
set, denoted by ∅, is a set that satises the following:
∀x x ∈/ ∅, where ∈/ means "is not in" or "is not a member of".
Note that ∅ and {∅} are dierent sets. {∅} has one element namely ∅ in it. So {∅} is not empty. But ∅
has nothing in it.
Denition (Universal set): A set which has all the elements in the universe of discourse is called a universal
set.
More formally, a universal set, denoted by U, is a set that satises the following: ∀x x ∈U.
Three subset relationships involving empty set and universal set are listed below as theorems without
proof.
Note that the set A in the next four theorems are arbitrary. So A can be an empty set or universal set.
Theorem 1: For an arbitrary set A A ⊆U.
Theorem 2: For an arbitrary set A ∅ ⊆A.
Theorem 3: For an arbitrary set A A ⊆A.
Denition (Power set): The set of all subsets of a set A is called the power set of A and denoted by 2A
or P(A) .
For example for A = {1, 2}, P(A) = {∅, {1}, {2}, {1, 2} } .
For B = {{1, 2}, {{1}, 2}, ∅} , P(B) = {∅, {{1, 2}}, {{{1}, 2}}, {∅}, { {1, 2}, {{1}, 2 }}, { {1, 2}, ∅}, {
{{1}, 2}, ∅}, {{1, 2}, {{1}, 2}, ∅} } .
Also P(∅) = {∅} and P({∅}) = {∅, {∅}} .
Theorem 4: For an arbitrary set A, the number of subsets of A is 2|A|.
http://cnx.org/content/m15772/1.1/
Connexions module: m15772 3
Mathematical theories are constructed starting with some fundamental assumptions, called axioms, such
as "sets exist" and "objects belong to a set" in the case of naive set theory, then proceeding to dening
concepts(denitions) such as "equality of sets", and "subset", and establishing their properties and rela-
tionships between them in the form of theorems such as "Two sets are equal if and only if each is a subset
of the other", which in turn causes introduction of new concepts and establishment of their properties and
relationships. Proofs are the arguments for establishing those properties and relationships. At the bottom
level these arguments follow the inference rules of propositional and predicate logic, that is the conclusion
of the theorem being proved must be derived from its hypotheses, axioms, denitions, and proven theorems
using inference rules. However, at the bottom level they become tedious and inecient as one can easily
imagine. Thus in actual proofs short-cuts are taken using already proven theorems, using multiple inference
rules in one step without explicitly mentioning them individually, omitting "obvious" proofs, and so on.
Finding a proof is in general an art. There is no single method that works for all cases. However, at this
level the most important thing to remember is to know and understand denitions of concepts involved. The
next important thing to keep in mind is to look up relevant facts and try to use them. Even if you don't see
the entire path to the goal, if you move one step forward from where you are, you get a new perspective and
it often gives you some good ideas to pursue. Needless to say that you must not forget the inference rules.
It is not a bad idea to review "Problem Solving" we studied earlier here.
There are also some well used and often very useful proof techniques such as trivial proof, vacuous proof,
direct proof, proof by contradiction, proving the contrapositive, and proof by induction. These are explained
below with proofs of the theorems on subset relation as examples.
Theorem 1: A ⊆ U.
Proof: By the denition of ⊆ , we need to show that ∀x [x ∈ A → x ∈ U].
For that, what we need is to show that for an arbitrary x, x ∈ A → x ∈ U holds according to the inference
rule "universal generalization".
Since x is an object of the universe of discourse, x ∈ U is true for any arbitrary object by the Universal
Instantiation. Hence x ∈ A → x ∈ U is true for any arbitrary object x (p→ q is always true if q is true
regardless of what p is). Thus by the Universal Generalization ∀x [x ∈ A → x ∈ U], that is, A ⊆ U by the
denition of subset.
We say p→ q is trivially true if q is true, and this kind of proof (i.e. showing q is true for p→ q without
referring to p) is called a trivial proof.
Theorem 2: ∅ ⊆ A.
Proof: By the denition of ⊆ , we need to show that ∀x [x ∈ ∅ → x ∈ A]. For that, what we need is to
show that for an arbitrary x, x ∈ ∅ → x ∈ A holds. Then apply the Universal Generalization.
Since ∀x x ∈ / ∅, for any arbitrary x, x ∈ ∅ is false by the Universal Instantiation.
Hence x ∈ ∅ → x ∈ A is true for any arbitrary x (p→ q is always true if p is false regardless of what q
is). Hence by the Universal Generalization ∀x [x ∈ ∅ → x ∈ A]. Thus ∅ ⊆ A by the denition of subset.
We say p→ q is vacuously true if p is false, and this kind of proof (i.e. showing p is false for p → q) is
called a vacuous proof.
Proof Variations for Theorem 2
Theorem 2, like most others, can be proven in a number of other ways. Here we try to prove it in two
other ways.
(1) Proof by Contrapositive:
In this method, to prove p → q we prove its contrapositive, ¬q → ¬p, instead. So to prove x ∈ ∅ → x ∈
A for an arbitrary x, try to prove x ∈ /A→x∈ / ∅. In this case since x ∈
/ ∅ is true for any arbitrary x, x ∈
/A
→x∈ / ∅ is trivially true. Hence its contrapositive x ∈ ∅ → x ∈ A is also true.
(2) Proof by Contradiction:
In this method, to prove p we assume ¬p and derive a contradiction from that. Then since ¬p implies a
contradiction, it can not hold true. Hence p must be true.So to prove ∀x [x ∈ ∅ → x ∈ A] we assume that
http://cnx.org/content/m15772/1.1/
Connexions module: m15772 4
¬∀x [x ∈ ∅ →Vx ∈ A]. ¬∀x [x ∈ ∅ → x ∈ A] is equivalent to ∃x ¬[x ∈ ∅ → x ∈ A]. This in turn is equivalent
to ∃x [x ∈ ∅ x∈/ A]. V
However, ∃x [x ∈ ∅ x ∈ / A] implies ∃x [x ∈ ∅] by formula 4 of the relationships between the connectives
and quantiers from predicate logic and "simplication" from the implications of propositional logic. But x
/ ∅ for any x, which contradicts ∃x [x ∈ ∅]. Hence, ¬∀x [x ∈ ∅ → x ∈ A] can not be true. Hence, ∅ ⊆ A.
∈
More Proofs
Theorem 3: A = B i A⊆ B and B⊆ A
Proof: By the denition of A = B,
A = B ⇔∀x [x ∈ A ↔ xV∈ B]
⇔∀x [(x ∈ A → x ∈ B)V (x ∈ B → x ∈ A) ]
⇔∀x [x ∈ A → x ∈ B] ∀x [ (x ∈ B → x ∈ A) ]
Since A⊆ B ⇔∀x [ (x ∈A → x ∈B) ], this means that A⊆ B and B⊆ A.
Hence, A = B i AV⊆ B and B⊆ A.
Theorem 4: A⊆B B⊆VC → A⊆ CProof: A⊆B B⊆C
V
⇔∀x [x ∈ A → x ∈ B] V∀x [ (x ∈ B → x ∈ C) ]
⇔∀x [(x ∈ A → x ∈ B) (x ∈ B → x ∈ C) ]
Thus for an arbitrary x in the universe, Z, and x ∈ B → x ∈ C holds.Hence, by hypothetical syllogism x
∈ A → x ∈ C,Hence, A⊆ C.
Sets can be combined in a number of dierent ways to produce another set. Here four basic operations are
introduced and their properties are discussed.
Denition (Union): The union of sets A and B, denoted by A ∪B, is the set dened as
A ∪B = {x | x ∈A ∨ x ∈B}
Example 1: If A = {1, 2, 3} and B = {4, 5}, then A ∪B = {1, 2, 3, 4, 5}.
Example 2: If A = {1, 2, 3} and B = {1, 2, 4, 5}, then A ∪B = {1, 2, 3, 4, 5}.
Note that elements are not repeated in a set.
Denition (Intersection): The intersection of sets A and B, denoted by A ∩B, is the set dened as
A ∩B = {x | x ∈A x ∈B}
V
Example 3: If A = {1, 2, 3} and B = {1, 2, 4, 5}, then A ∩B = {1, 2}.
Example 4: If A = {1, 2, 3} and B = {4, 5}, then A ∩B = ∅.
Denition (Dierence):
V The dierence of sets A from B, denoted by A - B, is the set dened as
A - B = {x | x ∈A x∈/ B}
Example 5: If A = {1, 2, 3} and B = {1, 2, 4, 5}, then A - B = {3}.
Example 6: If A = {1, 2, 3} and B = {4, 5}, then A - B = {1, 2, 3}.
Note that in general A - B6= B - A
Denition (Complement): For a set A, the dierence U - A, where U is the universe, is called the
complement of A and it is denoted by A.
Thus A is the set of everything that is not in A.
The fourth set operation is the Cartesian product. We rst dene an ordered pair and Cartesian product
of two sets using it. Then the Cartesian product of multiple sets is dened using the concept of n-tuple.
Denition (ordered pair):
An ordered pair is a pair of objects with an order associated with them. If objects are represented by x
and y, then we write the ordered pair as <x, y>.
Two ordered pairs <a, b> and <c, d> are equal if and only if a = c and b = d. For example the ordered
pair <1, 2> is not equal to the ordered pair <2, 1>.
Denition (Cartesian product):
The set of all ordered pairs <a, b>, where a is an element of A and b is an element of B, is called the
Cartesian product of A and B and is denoted by A×B.
http://cnx.org/content/m15772/1.1/
Connexions module: m15772 5
Example 1: Let A = {1, 2, 3} and B = {a, b}. Then A × B = {<1, a>, <1, b>, <2, a>, <2, b>, <3,
a>, <3, b>}.
Example 2: For the same A and B as in Example 1,
B ×A = {<a, 1>, <a, 2>, <a, 3>, <b, 1>, <b, 2>, <b, 3>}.
As you can see in these examples, in general, A ×B 6=B ×A unless A = ∅, B = ∅ or A = B.
Note that A × ∅= ∅ × A = ∅ because there is no element in ∅ to form ordered pairs with elements of A.
The concept of Cartesian product can be extended to that of more than two sets. First we are going to
dene the concept of ordered n-tuple.
Denition (ordered n-tuple): An ordered n-tuple is a set of n objects with an order associated with them
(rigorous denition to be lled in). If n objects are represented by x1, x2, ..., xn, then we write the ordered
n-tuple as <x1, x2, ..., xn> .
Denition (Cartesian product): Let A1, ..., An be n sets. Then the set of all ordered n-tuples <x1, ...,
xn> , where xi∈Ai for all i, 1 ≤ i ≤ n , is called the Cartesian product of A1, ..., An, and is denoted by A1
×... ×An .
Example 3:
Let A = {1, 2}, B = {a, b} and C = {5, 6}. Then A ×B ×C = {<1, a, 5>, <1, a, 6>, <1, b, 5>, <1,
b, 6>, <2, a, 5>, <2, a, 6>, <2, b, 5>, <2, b, 6>}.
Denition (equality of n-tuples): Two ordered n-tuples <x1, ..., xn> and <y1, ..., yn> are equal if and
only if xi = yi for all i, 1 ≤i ≤n.
For example the ordered 3-tuple <1, 2, 3> is not equal to the ordered n-tuple <2, 3, 1>.
Basic properties of set operations are discussed here. 1 - 6 directly correspond to identities and implications
of propositional logic, and 7 - 11 also follow immediately from them as illustrated below.
1. A ∪ ∅ = A
A∩U=A
- Identity Laws
2. A ∪ U = U
A∩∅=∅
- Domination Laws
3. A ∪ A = A
A∩A=A
- Idempotent Laws
4. A ∪ B = B ∪ A
A ∩ B = B ∩A
- Commutative Laws
5. (A ∪ B) ∪ C = A ∪ (B ∪ C)
(A ∩ B) ∩ C = A ∩ (B ∩ C)
- Associative Laws
6. A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C)
A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)
- Distributive Laws
7. If A⊆B and C⊆D, then A ∪ C ⊆ B ∪ D, and A ∩ C ⊆ B ∩ D
8. If A⊆B, then A ∪ B = B and A ∩ B = A
9. A ∪ (B - A) = A ∪ B
10. A ∩ (B - A) = ∅
11. A - (B ∪ C) = (A B) ∩ (A - C) (cf. A ∪ B = A ∩ B )
A - (B ∩ C) = (A - B) ∪ (A - C) (cf. A ∩ B = A ∪ B )
- De Morgan's Laws
12. B = A if and only if A ∪ B = U and A ∩ B = ∅
http://cnx.org/content/m15772/1.1/
Connexions module: m15772 6
13. A = A
Additional properties:
14. A ⊆A ∪B
15. A∩B ⊆A
The properties 1∼6, and 11 can be proven using equivalences of propositional logic. The others can also
be proven similarly by going to logic, though they can be proven also using some of these properties (after
those properties are proven, needless to say). Let us prove some of these properties.
Proof for 4: A ∪ B = B ∪ A
We are going to prove this by showing that every element that is in A∪B is also in B∪A and vice versa.
Consider an arbitrary element x. Then by the denition of set union x ∈ A ∪ B ⇔ x ∈A ∨ x ∈ B
⇔ x ∈A ∨ x ∈ B by the commutativity of ∨
⇔ x ∈ B ∪ A by the denition of set union.
Hence by Universal Generalization, every element is in A ∪B is also in B ∪A.
Hence A ∪ B = B ∪ A.
Note here the correspondence of the commutativity of ∪ and that of ∨. This correspondence holds not
just for the commutativity but also for others.
Furthermore a similar correspondence exists between ∩ and , and between ⊆ and →.
V
Proof for 6: By the denition of the equality of sets, we need to prove that ∀x [x ∈ A ∪ (B ∩ C)] if and
only if x ∈ (A ∪ B) ∩ (A ∪ C).
For that, considering the Universal Generalization rule, we need to show that for an arbitrary element in
the universe x, x ∈ A ∪ (B ∩ C) if and only if x ∈ (A ∪ B) ∩ (A ∪ C).
Here the only if part is going to be proven. The if part can be proven similarly.
x ∈ A ∪ (B ∩ C) ⇔Vx ∈ A ∨ x ∈ (B ∩ C) by the denition of ∪
⇔ x ∈ A ∨ (x ∈ B Vx ∈ C) by the denition of ∩
⇔ (x ∈ A ∨ x ∈VB) (x ∈ A ∨ x ∈ C) by the distribution from the equivalences of propositional logic
⇔ x ∈ (A ∪ B) x ∈ (A ∪ C) by the denition of ∪.
⇔ x ∈ (A ∪ B) ∩ (A ∪ C) by the denition of ∩.
Proof for 8: (a) If A⊆B then A ∪ B = B.
Let x be an arbitrary element in the universe.
Then x ∈ A ∪ B ⇔ x ∈ A ∨ x ∈ B.
Since A⊆B, x ∈ A → x ∈ B
Also x ∈ B → x ∈ B
Hence x ∈ A ∪ B → x ∈ B.
Hence A ∪ B ⊆ B
Since B ⊆ A ∪ B (use "addition" rule), A ∪ B = B follows.
(b) Similarly for A ∩ B = A.
Alternative proof:
These can also be proven using 8, 14, and 15. For example, (b) can be proven as follows:
First by 15, A ∩B ⊆A.
Then since A ⊆A, and A ⊆B, by 7 A ∩A ⊆A ∩B.
Since A ∩A = A by 3, A ⊆A ∩B.
Proof for 9: Let x be an arbitrary element inVthe universe.
Then [x ∈ A ∪ (B - A)]V ⇔ [x ∈ A ∨ (x ∈ B x ∈ / A)]
⇔ [(x ∈ A ∨ x ∈ B) V (x ∈ A ∨ x ∈ / A)]
⇔ [(x ∈ A ∨ x ∈ B) True]
⇔ [x ∈ A ∨ x ∈ B]
Hence A ∪ (B - A) = A ∪ B.
Alternative proof
This can also proven using set properties as follows.
A ∪( B - A ) = A ∪( B ∩ A) by the denition of ( B - A ) .
= ( A ∪B ) ∩( A ∪ A) by the distribution.
http://cnx.org/content/m15772/1.1/
Connexions module: m15772 7
= (A ∪B ) ∩U
= ( A ∪B ) by 1.
Proof for 10: Suppose A ∩ (B - A) 6= ∅.
Then there is an element xV that is in A ∩ (B - A), i.e.
x ∈ A ∩ (B - A) ⇔ x ∈ A x∈BA
⇔ x ∈ A V(x ∈ B Vx ∈ / A)
V V
⇔ (x ∈ A x ∈ / A) x ∈ B
⇔ False
Hence A ∩ (B - A) 6= ∅ does not hold.
Hence A ∩ (B - A) = ∅.
This can also be proven in the similar manner to 9 above.
Proof for 11: Let x be an arbitrary
V element in the universe.
Then x ∈ V A - (B ∪ C)W⇔ x ∈ A x∈/B∪C
⇔ x ∈ A V ¬(x ∈ BV x ∈C)
⇔ x ∈ A V(x ∈ / B Vx ∈ / C)
⇔ (x ∈ A V x ∈ / B) V x ∈/C V
⇔ (x ∈ A xV∈ / B) (x ∈ A x ∈ / C)
⇔x∈A-B x∈A-C
⇔ x ∈ (A - B) ∩ (A - C)
Hence A - (B ∪ C) = (A B) ∩ (A - C)
Proof for 12: V
(a) A ∪ B = U A ∩ B = ∅ ⇒ B = A?
(b) Try to prove B ⊆ A and A ⊆ B.
Let x be an arbitrary element in the universe.
Then if x ∈ B, then x ∈/ A since A ∩ B = ∅. Hence x ∈ A.
Hence B ⊆ A.
If x ∈ A, then x ∈
/ A. Since x ∈ A ∨ x ∈ B (from A ∪ B = U ), x ∈ B
must hold. Hence A ⊆ B.
Hence B = A. (c) B = A ⇒ A ∪ B = U A ∩ B = ∅ ?
V
Since B = A, A ∪ B = A ∪ (U-A) = A ∪ U = U since A ⊆ U
Also A ∩ B = A ∩ (U - A) = ∅ by 10 above.
Proof for 13: Since A ∪ A = A ∪ A, A ∪ A= U
Also since A ∩ A = A ∩ A , A ∩ A = ∅.
Hence A satises the conditions for the complement of A.
Hence A = A.
http://cnx.org/content/m15772/1.1/
Connexions module: m15772 8
• A B = {e,f}
• B A = {e,f}
4. List the members of the following sets.
• {x | x is a real number such that x2 = 4}
• {x | x is an integer such that x2 =2}
5. Determine whether each of the following pairs of sets is equal.
1. {a}
2. {a, {a}}
3. {∅, {∅}}
4. Let A be a set. Show that ∅x A = A x ∅= ∅.
5. How many dierent elements does A x B have if A has m elements and B has n elements?
6. Let A = {1, 2, 3, 4} and b = {0, 3, 5}. Find
1. A ∪B
2. A ∩B
3. A - B
4. B - A
5. What can you say about the sets A and B if the following are true?
1. A ∪B
2. A ∪B = A
3. A - B = A
4. Let A and B be subsets of a universal set U. Show that A ⊆B if and only if B⊆ A.
5. Let A and B be sets. Show that
1. A ∪B = B ∪A.
2. A ∩B = B ∩A.
3. Show that if A and B are sets, then (A ∪ B)=A ∩ B by showing each side is a subset of the other
side.
4. Let A, B, and C be sets. Show that A ∪( B ∪C ) = ( A ∪B ) ∪C.
http://cnx.org/content/m15772/1.1/