Discrete Structures - Section 2
Discrete Structures - Section 2
Set theory is generally considered to be the foundation of all modern mathematics. This
means that most mathematical objects (numbers, relations, functions, etc.) are defined in
terms of sets.
Unfortunately for engineers, set theory is not quite as simple as it seems. It turns out that
simple approaches to set theory include paradoxes (e.g., statements which are both true
and false). These paradoxes can be resolved by putting set theory in a firm axiomatic
framework, but that exercise is rather unproductive for engineers.
Instead, we adopt what is called naive set theory which rigorously defines the operations
of set theory without worrying about possible contradictions.
This approach is sufficient for most of mathematics and also acts as a stepping-stone to
more formal treatments.
Definition
A set is taken to be any collection of objects, mathematical or otherwise. For example,
one can think of “the set of all KNUST students admitted in 2023”. The only thing that
matters to a set is the elements in it. The objects in a set are referred to as elements or
members of the set. One usually uses capital letters, A, B, X, Y, . . . , to denote sets, and
lowercase letters, a, b, x, y, . . . , to denote elements of sets.
A set is uniquely defined by its elements.
The logical statement “a is a member of the set A” is written
a ∈ A.
Mathematical examples of sets are N, the set of natural numbers, Z, the set of integers,
Q, the set of all rational numbers (i.e fractions) and R, the set of all real numbers.
Definition
Two sets are equal if and only if they have the same elements. Therefore, if A and B are
sets, then A and B are equal if and only if ∀x(x ∈ A ↔ x ∈ B). We write A = B if A and B
are equal sets.
There are several ways to describe a set. One way is to list all the members of a set, when
this is possible. We use a notation where all members of the set are listed between
braces. For example, the notation {a, b, c, d} represents the set with the four elements a,
b, c, and d. This way of describing a set is known as the roster method.
Example 1
The set V of all vowels in the English alphabet can be written as V = {a, e, i, o, u}.
Example 2
The set O of odd positive integers less than 10 can be expressed by O = {1, 3, 5, 7, 9}.
Example 4
The set of positive integers less than 100 can be denoted by {1, 2, 3, ..., 99}.
Another way to describe a set is to use set builder notation. We characterize all those
elements in the set by stating the property or properties they must have to be members.
The general form of this notation is {x|x has property P} and is read ”the set of all x such
that x has property P.” For instance, the set O of all odd positive integers less than 10 can
be written as
We often use this type of notation to describe sets when it is impossible to list all the
elements of the set.
Definition
Suppose A and B are sets. Then A is called a subset of B (denoted A ⊆ B) if, for every
element x, if x ∈ A we also have that x ∈ B. This means that
A ⊆ B ⇔ ∀x((x ∈ A) → (x ∈ B)).
As for the second statement. Every element of A is in B and every element of B is in A. But
as a set is uniquely defined by its elements, we find A = B. The statement
A ⊆ B and B ⊆ A then A = B may seem to be a trivial observation but it will be prove to
be very useful.
To prove this we first have to show that A ⊆ B by proving that each element x ∈ A is also
an element of B and then that B ⊆ A then A = B by proving that each y ∈ B is also in
A.
P. A. KWABI (Ph.D.) SET THEORY 15/119
Example
It is true that 1 ∈ {1, 2, 3} and {1} ⊆ {1, 2, 3} but not that 1 ⊆ {1, 2, 3} or
{1} ∈ {1, 2, 3}
Example
Notice that ϕ ∈ {ϕ} and ϕ ⊆ {ϕ}
All sets under investigation in any application of set theory are assumed to belong to some
fixed large set called the universal set denoted by U unless otherwise stated or implied.
Given a universal set U and a property P, there may not be any elements of U which have
property P. For example, the following set has no elements:
Such a set with no elements is called the empty set or null set and is denoted by ϕ
The empty set ϕ is also regarded as a subset of every other set. Thus we have the
following simple result which we state formally.
Proof.
We will prove the first part and leave the proof of the second part as an exercise.
Let A be a set. To show that ϕ ⊆ A, we must show that ∀x(x ∈ ϕ → x ∈ A) is true.
Because the empty set contains no elements, it follows that x ∈ ϕ is always false. It
follows that the conditional statement x ∈ ϕ → x ∈ A is always true, because its
hypothesis is always false and a conditional statement with a false hypothesis is true.
Therefore, ∀x(x ∈ ϕ → x ∈ A) is true. This completes the proof of the first. Note that
this is an example of a vacuous proof.
John Venn, (4 August 1834 – 4 April 1923) was an English mathematician, logician and
philosopher noted for introducing Venn diagrams, which are used in logic, set theory,
probability, statistics, and computer science.
There are also a number of operations between sets. Let A, B be any two sets.
Definition
The union of A and B (denoted A ∪ B) is the set of elements in either A or B. This is
illustrated with a Venn diagram in figure 3.
Definition
The intersection of A and B (denoted A ∩ B) is the set of all elements contained in both A
and B. This is illustrated with a Venn diagram in figure 4.
A ∪ B = {1, 2, 3, 4, 5, 6, 7} , A ∪ C = {1, 2, 3, 4, 8, 9}
B ∪ C = {2, 3, 4, 5, 6, 7, 8, 9} ,
A ∩ B = {3, 4} , A ∩ C = {2, 3} , B ∩ C = {3} .
Example
Let A = {1, 3, 5, 7, 9} and B = {2, 4, 6, 8, 10}.
A∩B=ϕ
Because unions and intersections of sets satisfy associative laws, the sets A ∪ B ∪ C and
A ∩ B ∩ C are well defined; that is, the meaning of this notation is unambiguous when A,
B, and C are sets. That is, we do not have to use parentheses to indicate which operation
comes first because A ∪ (B ∪ C) = (A ∪ B) ∪ C and A ∩ (B ∩ C) = (A ∩ B) ∩ C. Note that
A ∪ B ∪ C contains those elements that are in at least one of the sets A, B, and C, and that
A ∩ B ∩ C contains those elements that are in all of A, B, and C. These combinations of the
three sets, A, B, and C, are shown in Figure 5.
Solution: The set A ∪ B ∪ C contains those elements in at least one of A, B, and C. Hence,
A ∪ B ∪ C = {0, 1, 2, 3, 4, 6, 8, 9}. The set A ∩ B ∩ C contains those elements in all three
of A, B, and C. Thus, A ∩ B ∩ C = {0}
and
∞
\ ∞
\
Ai = {1, 2, 3, ..., i} = 1
i=1 i=1
Theorem
Suppose A and B are finite sets. Then A ∪ B and A ∩ B are finite and
That is, we find the number of elements in A or B (or both) by first adding n(A) and n(B)
(inclusion) and then subtracting n(A ∩ B) (exclusion) since its elements were counted twice.
We can apply this result to obtain a similar formula for three sets:
Suppose A, B, C are finite sets. Then A ∪ B ∪ C is finite and
n(A ∪ B ∪ C)
= n(A) + n(B) + n(C) − n(A ∩ B) − n(A ∩ C) − n(B ∩ C) + n(A ∩ B ∩ C)
P. A. KWABI (Ph.D.) SET THEORY 39/119
EXERCISE
Suppose a list A contains the 30 students in a mathematics class, and a list B contains the
35 students in an English class, and suppose there are 20 names on both lists. Find the
number of students:
1. only on list A,
2. only on list B,
3. on list A or B (or both),
4. on exactly one list.
Ac = {x|x ∈ U, x ∈
/ A}
Definition
The relative complement of a set B with respect to a set A or, simply, the difference of A
and B, denoted by A \ B, is the set of elements which belong to A but which do not belong
to B; that is
A\B = {x|x ∈ A, x ∈
/ B}
Definition
The symmetric difference of sets A and B, denoted by A B, consists of those elements
L
which belong to A or B but not to both. That is,
M M
A B = (A ∪ B)\(A ∩ B) or A B = (A\B) ∪ (B\A)
The Cartesian product is named after René Descartes, whose formulation of analytic
geometry gave rise to the concept, which is further generalized in terms of direct product.
Figure 7: 7: 800px-franshals-portretvanrenedescartes
An example of Cartesian product is the real plane R2 , where R is the set of real numbers
(R is sometimes called real line)
Sets under the operations of union, intersection, and complement satisfy various laws
(identities) which are listed in the table below:
Associative Laws: A ∪(B ∪ C) = (A ∪ B)∪ C
A ∩(B ∩ C) = (A ∩ B)∩ C
Commutative Law: A ∪B = B ∪ A
A ∩B = B ∩ A
Distributive Laws: A ∪(B ∩ C) = (A ∪ B) ∩ (A ∪ C)
A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C)
Identity Laws: A∪ϕ=A
A∩U =A
Taking a careful look at the laws of algebra listed in the table above, you realize that all the
laws are two with exception to the Involution law. One may ask why is it so?.
Definition
Suppose P is an equation of set algebra. The dual P∗ of P is the equation obtained by
replacing each occurrence of ∪, ∩, U and ϕ in P by ∩, ∪, ϕ, and U, respectively.
For example, the dual of (U ∩ A) ∪ (B ∩ A) = A is (ϕ ∪ A) ∩ (B ∪ A) = A
Observe that the pairs of laws in the tables above are duals of each other. It is a fact of set
algebra, called the principle of duality, that if any equation P is an identity then its dual P∗
is also an identity.
Proof.
We will prove that the two sets A ∩ B and A ∪ B are equal by showing that each set is a
subset of the other.
First, we will show that A ∩ B ⊆ A ∪ B We do this by showing that if x is in A ∩ B, then it
must also be in A ∪ B Now suppose that x ∈ A ∪ B. By the definition of complement,
x∈ / A ∩ B Using the definition of intersection, we see that ¬((x ∈ A) ∧ (x ∈ B)) is true.
By applying De Morgan’s law for propositions, we see that ¬(x ∈ A) or ¬(x ∈ B). Using
the definition of negation of propositions, we have x ∈/ A or x ∈
/ B. Using the definition of
the complement of a set, we see that this implies that x ∈ A or x ∈ B. Consequently, by
the definition of union, we see that x ∈ A ∪ B. We have now shown that A ∩ B ⊆ A ∪ B
P. A. KWABI (Ph.D.) SET THEORY 56/119
Proof (Cont.)
Next, we will show that A ∪ B ⊆ A ∩ B. We do this by showing that if x is in A ∪ B then it
must also be in A ∩ B. Now suppose that x ∈ A ∪ B. By the definition of union, we know
that x ∈ A or x ∈ B. Using the definition of complement, we see that x ∈ / A or x ∈/ B..
Consequently, the proposition ¬(x ∈ A) ∨ ¬(x ∈ B) is true. By De Morgan’s law for
propositions, we conclude that ¬((x ∈ A) ∧ (x ∈ B)) is true. By the definition of
intersection, it follows that ¬(x ∈ A ∩ B). We now use the definition of complement to
conclude that x ∈ A ∩ B This shows that A ∪ B ⊆ A ∩ B
Because we have shown that each set is a subset of the other, the two sets are equal, and
the identity is proved.
Proof.
We will prove this identity by showing that each side is a subset of the other side.
Suppose that x ∈ A ∩ (B ∪ C). Then x ∈ A and x ∈ B ∪ C. By the definition of union, it
follows that x ∈ A, and x ∈ B or x ∈ C (or both). In other words, we know that the
compound proposition (x ∈ A) ∧ ((x ∈ B) ∨ (x ∈ C)) is true. By the distributive law for
conjunction over disjunction, it follows that ((x ∈ A) ∧ (x ∈ B)) ∨ ((x ∈ A) ∧ (x ∈ C)). We
conclude that either x ∈ A and x ∈ B, or x ∈ A and x ∈ C.
Proof.
We have
There are three different methods for proving set identities, namely:
1. Subset method: Show that each side of the identity is a subset of the other side.
2. Membership table or Truth table: For each possible combination of the atomic sets,
show that an element in exactly these atomic sets must either belong to both sides
or belong to neither side
3. Apply existing identities: Start with one side, transform it into the other side using a
sequence of steps by applying an established identity.
We will encounter the second method which is membership or truth table when we start
Logic and propositional calculus.
Definition
Let S be a set. If there are exactly n distinct elements in S where n is a nonnegative
integer, we say that S is a finite set and that n is the cardinality of S. The cardinality of S is
denoted by —S—.
Remark : The term cardinality comes from the common usage of the term cardinal
number as the size of a finite set.
Example
Let A be the set of odd positive integers less than 10. Then |A| = 5.
Example
Let S be the set of letters in the English alphabet. Then |S| = 26.
Every set falls withing these two categories; finite and infinite.
Definition
A set S is said to be finite provided either it is empty or there is a natural number n for
which S is equipotent to {1, ..., n}; otherwise S is infinite. If S is said to be equipotent to
1, 2, ..., n it means S is one-to-one to the set.
We say that, S is countably infinite provided S is equipotent to the set N of natural
numbers. A set that is either finite or countably infinite is said to be countable. A set that
is not countable is called uncountable.
Definition
The number of elements in a set is known as the cardinality of the set.
The notation n(S) or —S— will denote the number of elements in a set S. (Some texts use
#(S) or card(S) instead of n(S).) Thus n(A) = 26, where A is the letters in the English
alphabet, and n(D) = 7, where D is the days of the week. Also n(ϕ) = 0 since the empty
set has no elements.
Lemma
Suppose S is the disjoint union of finite sets A and B. Then S is finite and
For example, suppose an art class A has 25 students and 10 of them are taking a biology
class B. Then the number of students in class A which are not in class B is:
Definition
Suppose S = {a, b, c, d}, then
The elements of B are the sets {a, b, c} , {a, b, d} , {a, c, d}. Thus B is a subclass of A,
since every element of B is also an element of A.
Definition
Given a set S, the classes of all subsets of S is called the power set of S denoted by P(S).
The number of elements in P(S) is determined by 2 raised to the power n(S). That is,
n(P(S)) = 2n(S)
EXAMPLE
Given that S = {1, 2, 3}. Then
Note that the empty set ϕ belongs to P(S) since ϕ is a subset of S. Similarly, S belongs to
P(S). As expected from the above remark, P(S) has 23 = 8 elements.
Solution: The empty set has exactly one subset, namely, itself. Consequently,
P(ϕ) = {ϕ} .
The set {ϕ}? has exactly two subsets, namely, ϕ and the set {ϕ} itself. Therefore,
P({ϕ}) = ϕ, {ϕ}.
Definition
Let S be a nonempty set. A partition of S is a subdivision of S into nonoverlapping,
nonempty subsets. Precisely, a partition of S is a collection Ai of nonempty subsets of S
such that:
1. Each a in S belongs to one of the Ai .
2. The sets of {Ai } are mutually disjoint; that is, if
Aj ̸= Ak then Aj ∩ Ak = ϕ
The subsets in a partition are called cells. Figure 8 is a Venn diagram of a partition of the
rectangular set S of points into five cells, A1 , A2 , A3 , A4 , A5 .
Partitions
Figure 8: 8
P. A. KWABI (Ph.D.) SET THEORY 77/119
EXERCISE
Consider the following collections of subsets of S = {1, 2, ..., 8, 9}:
1. [{1, 3, 5} , {2, 6} , {4, 8, 9}]
2. [{1, 3, 5} , {2, 4, 6, 8} , {5, 7, 9}]
3. [{1, 3, 5} , {2, 4, 6, 8} , {7, 9}]
Verify as to whether each of them is a partition of S or not.
Assume that we have a set of men M and a set of women W, some of whom are married.
We want to express which men in M are married to which women in W. One way to do
that is by listing the set of pairs (m, w) such that m is a man, w is a woman, and m is
married to w. So, the relation “married to” can be represented by a subset of the
Cartesian product M × W.
Definition
In general, a relation ℜ from a set A to a set B will be understood as a subset of the
Cartesian product A × B, i.e., ℜ ⊆ A × B. If an element a ∈ A is related to an element
b ∈ B, we often write aℜb instead of (a, b) ∈ ℜ.
• Arrow diagrams, Venn diagrams and arrows can be used for representing relations
between given sets.
• As an example, the figure below represents the relation from A = a, b, c, d to
B = 1, 2, 3, 4 given by R = (a, 1), (b, 1), (c, 2), (c, 3). In the diagram an arrow from
x to y means that x is related to y.
a 1
b 2
c 3
d 4
P. A. KWABI (Ph.D.) SET THEORY 83/119
• This kind of graph is called directed graph or digraph.
• Matrix of a Relation. Another way of representing a relation ℜ from A to B is with a
matrix.
• Its rows are labeled with the elements of A, and its columns are labeled with the
elements of B. If a ∈ A and b ∈ B then we write 1 in row a column b if a ℜ b,
otherwise we write 0.
• For instance the relation R = {(a, 1),(b, 1),(c, 2),(c, 3)} from A = {a, b, c, d} to B = {1, 2,
3, 4} has the following matrix.
1234
1 0 0 0
1 0 0 0
abcd 0 1 1 0
0 0 0 0
Definition
Given a relation ℜ from A to B, the inverse of R, denoted ℜ−1 , is the relation from B to A
defined as
bℜ−1 a ⇔ aℜb
.
• For instance, if ℜ is the relation “being a son or daughter of”, then ℜ−1 is the relation
“being a parent of”.
Definition
Let A, B and C be three sets. Given a relation R from A to B and a relation S from B to C,
then the composition S ◦ ℜ of relations ℜ and S is a relation from A to C defined by:
a(S ◦ ℜ)c ⇔there exists some b ∈ B such that a ℜ b and b S c .
A partial order, or simply, an order on a set A is a binary relation “≼” on A with the
following properties:
1. Reflexive: for all x ∈ A, x ≼ x.
2. Antisymmetric: (x ≼ y) ∧ (y ≼ x) ⇒ x = y.
3. Transitive: (x ≼ y) ∧ (y ≼ z) ⇒ x ≼ z.
ExampleS
1. The non-strict inequality (≤) in Z.
2. Relation of divisibility on Z+ : a|b ⇔ ∃t, b = at.
3. Set inclusion (⊆) on P(A) (the collection of subsets of a given set A).
EXERCISE
EXERCISE: prove that the aforementioned relations are in fact partial orders.
QUESTION
QUESTION: is the strict inequality (¡) a partial order on Z?
Definition
Two elements a, b ∈ A are said to be comparable if either x ≼ y or y ≼ x, otherwise they
are said to be non comparable.
• The order is called total or linear when every pair of elements x, y ∈ A are
comparable.
• For instance (Z, ≤) is totally ordered, but (Z+ , |), where “|” represents integer
divisibility, is not.
• A totally ordered subset of a partially ordered set is called a chain; for instance the
set {1, 2, 4, 8, 16, ...} is a chain in (Z+ , |).
Definition
A Hasse diagram is a graphical representation of a partially ordered set in which each
element is represented by a dot (node or vertex of the diagram). Its immediate successors
are placed above the node and connected to it by straight line segments.
Example
As an example, figure 9 represents the Hasse diagram for the relation of divisibility on
{1, 2, 3, 4, 5, 6, 7, 8, 9}.
Figure 9:
P. A. KWABI (Ph.D.) SET THEORY 92/119
QUESTION
QUESTION: Question: How does the Hasse diagram look for a totally ordered Set?
Example
1. For instance, on Z, the equality (=) is an equivalence relation.
2. Another example, also on Z, is the following: x ≡ y(mod 2) (“x is congruent to y
modulo 2”) iff x − y is even. For instance, 6 ≡ 2(mod 2) because 6 − 2 = 4 is even,
but 7 ̸≡ 4(mod 2), because 7 − 4 = 3 is not even. Congruence modulo 2 is in fact an
equivalence relation.
Definition
Given an equivalence relation ∼ on a set A, and an element x ∈ A, the set of elements of
A related to x are called the equivalence class of x, represented [x] = y ∈ A|y ≡ x.
Element x is said to be a representative of class x [x].
The collection of equivalence classes, represented A/ ∼= [x]| ∈ A, is called quotient set
of A by ∼.
Exercise
Find the equivalence classes on Z with the relation of congruence modulo 2.
Example
In Z with the relation of congruence modulo 2 (call it “∼2 ”), there are two equivalence
classes: the set E of even integers and the set O of odd integers. The quotient set of Z by
the relation “∼2 ” of congruence modulo 2 is“Z ∼2 ”) = {E, O}. We see that it is in fact a
partition of Z, because E ∩ O = ϕ, and Z = E ∪ O
Exercise
On the Cartesian product Z × Z∗ we define the relation (a, b) ℜ (c, d) ⇔ ad = bc. Prove
that ℜ is an equivalence relation. Would it still be an equivalence relation if we extend it
to Z × Z∗
−1 1
1 4
2 16
−2 9
Domain Range
b 1
c 2
d 3
e 4
1. one-to-one or injective
2. onto or surjective
3. one-to-one correspondence or bijective
one-to-one or injective
A function f : A → B is called one-to-one or injective if each element of B is the image of
at most one element of A.
Definition
A function f : A → B is called onto or surjective if every element of B is the image of some
element of A.
∀y ∈ B, ∃x ∈ A such that y = f (x).
For instance, f (x) = x2 from R to R2 ∪ {0} is onto.
a 0
e
b 1
f
c 2
g
d 3
h
e 4
Definition
A function f : A → B is said to be a one-to-one correspondence, or bijective, or a
bijection, if it is one-to-one and onto.
For instance, f (x) = x + 3 from Z to Z is a bijection.
b 1
c 2
d 3
e 4
Identity Function
Given a set A, the function 1A : A → A defined by 1A (x) = x for every x in A is called the
identity function for A.
Definition
Given two functions f : A → B and g : B → C, the composite function of f and g is the
function g ◦ f : A → C defined by (g ◦ f )(x) = g(f (x)) for every x in A.
f g
A→
− B→
− C
For instance, if A = B = C = Z, f (x) = x + 1, g(x) = x2 , then
(g ◦ f )(x) = f (x)2 = (x + 1)2 . Also (f ◦ g)(x) = g(x) + 1 = x2 + 1 (the composition of
functions is not commutative in general).
f −1 ◦ f = 1A
and
f ◦ f −1 = 1B .
Definition
A function from A × A to A is called a binary operator on A. For instance the addition of
integers is a binary operator + : Z × Z → Z.
• In the usual notation for functions the sum of two integers × and y would be
represented +(x, y). This is called prefix notation. The infix notation consists of
writing the symbol of the binary operator between its arguments: x + y (this is the
most common).
• There is also a postfix notation consisting of writing the symbol after the arguments:
(x y) +.
• Another example of binary operator on Z is (x, y) 7→ x · y.