Lecture Notes (1)
Lecture Notes (1)
▶ INTRODUCTION
▶ Relations
▶ Functions
▶ INTRODUCTION
▶ Relations
▶ Functions
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.
▶ INTRODUCTION
▶ Relations
▶ Functions
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.
Analogously we can define triples or 3-tuples (a, b, c), 4-tuples (a, b, c, d),. . . , n-tuples
(a1 , a2 , . . . , a1 ), and the corresponding 3-fold, 4-fold,. . . , n-fold Cartesian products:
An example of Cartesian product is the real plane R2 , where R is the set of real numbers
(R is sometimes called real line)
▶ INTRODUCTION
▶ Relations
▶ Functions
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 2: 8
P. A. KWABI (Ph.D.) SET THEORY 21/64
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.
▶ INTRODUCTION
▶ Relations
▶ Functions
Definition
A relation R from set A to set B is a subset of A × B.
Example
Let A = {tasks}, B = {tasks}. R = {(a, b) | a precedes b}.
EXAMPLE 1
Consider these relations on the set of integers:
R5 is not transitive because (2, 1) and (1, 0) belong to R5 , but (2, 0) does not.
R6 is not transitive because (2, 1) and (1, 2) belong to R6 , but (2, 2) does not.
P. A. KWABI (Ph.D.) SET THEORY 29/64
Examples on Properties of Relations
4 Relations
R4 is antisymmetric, because two elements are related with respect to R4 if and only
if they are equal.
R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)},
R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)},
R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)},
R6 = {(3, 4)}.
Which of the above relations are Reflexive, Symmetric, Transitive, and Antisymmetric?
P. A. KWABI (Ph.D.) SET THEORY 31/64
Examples on Properties of Relations
4 Relations
SOLUTION TO EXAMPLE 2
• The relations R3 and R5 are reflexive because they both contain all pairs of the form
(a, a), namely, (1, 1), (2, 2), (3, 3), and (4, 4).
The other relations are not reflexive because they do not contain all of these ordered
pairs. In particular, R1 , R2 , R4 , and R6 are not reflexive because (3, 3) is not in any
of these relations.
For R2 , the only thing to check is that both (2, 1) and (1, 2) are in the relation.
For R3 , it is necessary to check that both (1, 2) and (2, 1) belong to the relation, and
(1, 4) and (4, 1) belong to the relation.
For instance, R4 is transitive, because (3, 2) and (2, 1), (4, 2) and (2, 1), (4, 3) and
(3, 1), and (4, 3) and (3, 2) are the only such sets of pairs, and (3, 1), (4, 1), and
(4, 2) belong to R4 .
R1 is not transitive because (3, 4) and (4, 1) belong to R1 , but (3, 1) does not.
R3 is not transitive because (4, 1) and (1, 2) belong to R3 , but (4, 2) does not.
• R4 , R5 , and R6 are all antisymmetric. For each of these relations there is no pair of
elements a and b with a ̸= b such that both (a, b) and (b, a) belong to the relation.
Definition
A relation is an equivalence relation if it is reflexive, symmetric, and transitive.
Example
Group KNUST students by region: (a, b) ∈ R if a and b are from the same region.
Example
Is R = {(x, y) | x, y ∈ Z, x ≡ y (mod 3)} an equivalence relation?
• Reflexive: x ≡ x (mod 3) (True).
• Symmetric: If x ≡ y (mod 3), then y ≡ x (mod 3) (True).
• Transitive: If x ≡ y (mod 3) and y ≡ z (mod 3), then x ≡ z (mod 3) (True).
• Answer: Yes.
Definition
A relation is a partial order if it is reflexive, antisymmetric, and transitive.
Example
Task scheduling: (a, b) ∈ R if task a must precede b in a Ghanaian factory.
Example
Is R = {(x, y) | x ≤ y} on R a partial order?
• Reflexive: x ≤ x (True).
• Antisymmetric: If x ≤ y and y ≤ x, then x = y (True).
• Transitive: If x ≤ y and y ≤ z, then x ≤ z (True).
• Answer: Yes.
• Relations model database joins, e.g., linking customers to orders in Jumia Ghana.
def join_tables ( customers , orders ) :
return [( c , o ) for c in customers for o in orders if c .
id == o . customer_id ]
Example
Define a relation R on customers and orders where (c, o) ∈ R if customer c placed order
o.
• Is it reflexive? No, a customer doesn’t place an order with themselves.
• Is it symmetric? No, (c, o) ̸ =⇒ (o, c).
Problem
Is R = {(x, y) | x, y ∈ Z, x + y is even} an equivalence relation?
Problem
Is R = {(x, y) | x divides y} on Z+ a partial order?
Problem
Define a relation for KNUST students where (a, b) ∈ R if a and b are in the same
department. Is it an equivalence relation?
Problem
Write a Python function to check if a relation on tasks (e.g., precedence in a Ghanaian
factory) is transitive.
Problem
Model a relation linking KNUST students to courses. Is it reflexive, symmetric, or transitive?
▶ INTRODUCTION
▶ Relations
▶ Functions
Definition
A function f : A → B assigns each element of set A (domain) to exactly one element of
set B (codomain).
Example
Let A = {citizens}, B = {ID numbers}. Define f : A → B as f (citizen) = unique ID.
• Injective? Yes, each citizen has a unique ID.
• Surjective? Yes, if all IDs are assigned.
• Bijective? Yes, one-to-one correspondence.
Example
Is f : R → R, f (x) = x2 injective, surjective, or bijective?
• Injective: No, f (2) = f (−2) = 4.
√
• Surjective: No, no x maps to −1 (no real −1).
• Bijective: No, neither injective nor surjective.
Definition
For functions f : B → C and g : A → B, the composition (f ◦ g)(x) = f (g(x)).
Example
Let g : Students → Regions, g(student) = region, and f : Regions → Codes,
f (region) = code. Then (f ◦ g)(student) = code.
Example
Let f (x) = x + 1, g(x) = x2 . Compute (f ◦ g)(x) and (g ◦ f )(x).
• (f ◦ g)(x) = f (g(x)) = f (x2 ) = x2 + 1.
• (g ◦ f )(x) = g(f (x)) = g(x + 1) = (x + 1)2 .
Theorem
A function f : A → B has an inverse f −1 : B → A if and only if f is bijective.
Example
For f : Citizens → IDs, f −1 (ID) = citizen.
• Hash Function: Maps data to fixed-size values, e.g., for KNUST student database.
• Goal: Ideally injective to avoid collisions.
def hash_id ( student_id ) :
return student_id % 100 # Maps to 0 -99
Example
Design a hash function for KNUST student IDs: f (ID) = ID mod 10.
• Input: ID = 12345. Output: 12345 mod 10 = 5.
• Is it injective? No, IDs 12345 and 12355 map to 5.
Problem
Is f : Z → Z, f (x) = 2x injective? Surjective?
Problem
Let f (x) = 3x, g(x) = x − 2. Compute (f ◦ g)(x) and (g ◦ f )(x).
Problem
Define a function to map Ghanaian voters to polling stations. Is it injective? Surjective?
Problem
Write a Python function to map KNUST student IDs to department codes (e.g., 1 for CS, 2
for Math).
Problem
For f (x) = 2x + 1 from R → R, find f −1 (x).