1 0 Set Relation Function
1 0 Set Relation Function
Discrete Mathematics
Discrete Mathematics deals with
• “Separated” or discrete sets of objects
(rather than continuous sets)
• Processes with a sequence of individual steps
(rather than continuously changing processes)
Kind of problems solved by discrete mathematics
• How many ways are there to choose a computer password?
• What is the shortest path between two cities using a transportation system?
• How can a list of integers sorted in increasing order? How many steps are
required to do such a sorting?
Importance of Discrete Mathematics
• Information is stored and manipulated by computers in a discrete fashion
• Applications in many different areas
• Discrete mathematics is a gateway to more advanced courses
• Develops mathematical reasoning skills
Text book
10
Part 1
Chapter 0: Sets, Relations, Functions
Chapter 1: Counting problem
Chapter 2: Existence problem
Chapter 3: Enumeration problem
Chapter 4: Combinatorial optimization problem
11
Definitions
• Set and element
• Specification of set
12
Set and element
• Definition:
A set is an unordered collection of (unique) objects
The objects in a set are called elements or members of a set.
A set is said to contain its elements.
• Notation, for a set A:
x A: x is an element of A
x A: x is not an element of A
• Example:
V={a, e, i, o, u} (vowels in English)
C = all students subscribed to IT3020E in Winter 2020
• Note:
We often denote sets with capitals
{.} is used to define the set.
13
Set and element
• Definition: A multi-set is a set where you specify the number of occurrences
of each element: {m1a1,m2a2,…,mrar} is a set where:
• Element m1 occurs a1 times
• Element m2 occurs a2 times
•
• Element mr occurs ar times
14
Definitions
• Set and element
• Specification of set
15
Specification of set
• A set is defined in extension when you enumerate all the elements:
O={0,2,4,6,8}
• The set-builder notation
A = {x | conditions(x)}.
this could be read as “all x such that the conditions hold true”.
16
Specification of set
Well-known sets in math:
N = {0,1,2,3,...}
Z = {...,-2,-1,0,1,2,...}
Z+ = {1,2,3,...}
Q = {p/q | p in Z, q in Z, q is not 0}
R = {x | x is a real number}.
{,...} is used to indicate the rest of the sequence once it’s clear how to proceed
Example: {1,2,3,4,...}
17
Specification of set
• There is a set with no elements. It is called the empty set (or null set) and
denoted {} or .
• A set that has one element is called a singleton set.
For example: {a}, with brackets, is a singleton set
a, without brackets, is an element of the set {a}
• Note the subtlety in {} ??why
The left-hand side is the empty set
The right hand-side is a singleton set, and this set contains a set
18
Specification of set
• If there are exactly n distinct elements in a set S, with n is a nonnegative
integer, we say that:
S is a finite set, and
The cardinality of S is n. Notation: |S| = n.
• Definition. A set is a finite set if it has a finite number of elements. A set
that is not finite is an infinite set.
• Let A be a finite set. The number of different elements in A is called its
cardinality and is denoted by |A|. Other notations commonly used for the
cardinality of A are N(A), #A.
• If A is an infinite set, then we write |A| = .
• Example:
• || = 0 since contains no elements.
• |{π, 2, Newton}| = 3.
• If Nn = {0, 1, …, n} then | Nn | = n + 1.
• |{n: n is a prime number}| = ∞.
19
Content
• Definitions
• Set operations
• The algebra of sets
• Relations
• Functions
20
Set operations
• Set comparison
• Venn diagram
• Set operations
• Partition and cover
21
Set comparison
• Definition: Two sets, A and B, are equal if they contain the same elements.
We write A = B.
• Example:
{2,3,5,7} = {3,2,7,5}, because a set is unordered
Also, {2,3,5,7}={2,2,3,5,3,7} because a set contains unique elements
However, {2,3,5,7} {2,3}
22
Set comparison
• if P(x) and Q(x) are propositional functions which are true for the same
objects x, then the sets they define are equal, i.e.
{x : P(x)} = {x : Q(x)}.
23
Set comparison
• Definition: A is said to be a subset of B, if and only if every element of A is
also an element of B
that is: x (x A x B)
• Denote A B or B A,
24
Set comparison
• Definition: If A B and A B then set A is called a proper subset of set
B (that is there is an element xB such that xA)
• Denote: A B
• Example 1: A = { 1, 2, 3 }, B = { 2, 3, 1 }, C = { 3 }. Then:
B = A, C A, C B.
25
Set comparison
Examples:
N = {0, 1, 2, 3, ...} the set of natural numbers.
Z = {...,−2,−1, 0, 1, 2, ...} the set of integers.
Z+ : the set of positive integers
Q = {p/q : p, q Z and q ≠ 0} the set of fractions or rational numbers.
Q+ : the set of positive rational numbers
R = the set of real numbers;
R+ : the set of positive real numbers
C = {x + iy : x, y R and i2 = −1} the set of complex numbers.
26
Set operations
• Set comparison
• Venn diagram
• Set operations
• Partition and cover
27
Venn diagram
• Example: Draw the Venn diagram that represents 3 sets:
A = {1, 2, …, 10},
B = {2, 4, 6, 8, 12, 13},
C = {2, 3, 5, 7, 11, 13}
28
Set operations
• Set comparison
• Venn diagram
• Set operations
• Partition and cover
29
Set operations
• Union
A B = {x | x A or x B}
• Intersection
A B = {x | x A and x B}
• Set Subtraction
A – B (or A \ B) = {x | x A and x B}
30
Set Complement: Absolute & Relative
• Given the Universe U, and A,B U.
• The (absolute) complement of A is 𝐴ҧ = 𝑈\A
• The (relative) complement of A in B is B\A
U U
A A B
A
Set operations
• Set comparison
• Venn diagram
• Set operations
• Partition and cover
32
Partition and cover
• Let E ={𝐸𝑖 }𝑖∈𝐼 be a collection of subsets of the set M, 𝐸𝑖 𝑀. Collection E
will be called a cover of M if each element of M must be an element of at
least one of the sets of E :
• Example: M = {1, 2, 3, 4}
• E1 = {{1, 2}, {3, 4}} is a partition of M
• E2 = {{1, 2, 3}, {3, 4}} is not a partition of M
33
Content
• Definitions
• Set operations
• The algebra of sets
• Relations
• Functions
34
Power Set
• Definition: The power set of a set A, denoted P(A), is the set of all subsets
of A.
Examples {
Let A = { } →P (A) = {} ,
Let A = {a} →P (A) = {, {a}} {a}, {b}, {c},
Let A = {a, b} → P(A)= {, {a}, {b}, {a, b}} {a, b}, {a, c}, {b, c},
Let A = {a, b, c} → P(A) = ? {a, b, c}
}
• Note: the empty set and the set itself are always elements of the power
set.
Power Set
• Theorem: Let A be a set such that |A|=n, then |P(A)| = 2n
• Proof ?
Power Set
• For all sets A and B, the statement “A B if and only if P(A) P(B)” is
TRUE or FALSE?
Power Set
• For all sets A and B, the statement “A B if and only if P(A) P(B)” is
TRUE or FALSE?
• For all sets A and B, the statement “P(A) ∩ P(B) = P(A ∩ B)” is TRUE or
FALSE?
Power Set
• For all sets A and B, the statement “A B if and only if P(A) P(B)” is
TRUE or FALSE?
• For all sets A and B, the statement “P(A) ∩ P(B) = P(A ∩ B)” is TRUE or
FALSE?
• For all sets A and B, the statement “P(A) P(B) = P(A B)” is TRUE or
FALSE?
Power Set
• For all sets A and B, the statement “A B if and only if P(A) P(B)” is
TRUE or FALSE?
• For all sets A and B, the statement “P(A) ∩ P(B) = P(A ∩ B)” is TRUE or
FALSE?
• For all sets A and B, the statement “P(A) P(B) = P(A B)” is TRUE or
FALSE?
• For all sets A and B, the statement “P(A) P(B) P(A B)” is TRUE or
FALSE?
Properties of set operations
• Let A, B and C be any sets. The following laws hold
Equality Name
A=A Identity laws
AU=A
AU=U Domination laws
A=
AA=A Idempotent laws
AA=A
A 𝐴ҧ = U Complementation laws
A ∩ 𝐴ҧ =
ഥ =U
ഥ
𝑈=
( A) = A Involution laws
Properties of set operations
Equality Name
AB=BA Commutative laws
AB=BA
A (B C) = (A B) C Associative laws
A (B C) = (A B) C
A (B C) = (A B) (A C) Distributive laws
A (B C) = (A B) (A C)
AB = A B De Morgan’s laws
AB = A B
A ∩ (A B) = A Absorption laws
A (A ∩ B) = A.
Content
• Definitions
• Set operations
• The algebra of sets
• Relations
• Functions
43
Relations
• Ordered pair
• Cartesian product
• Binary relation
• Relation representation
• Operations on relations
• Properties of relations
44
Ordered pair
• An ordered pair is a set of a pair of objects with an order associated with
them.
• In general (x, y) is different from (y, x).
• Definition (equality of ordered pairs): Two ordered pairs (a, b) and (c, d)
are equal if and only if a = c and b = d.
• Example: if the ordered pair (a, b) is equal to (1, 2), then a=1, and b=2. (1,
2) is not equal to the ordered pair (2, 1).
45
Relations
• Ordered pair
• Cartesian product
• Binary relation
• Relation representation
• Operations on relations
• Properties of relations
46
Cartesian product René Descartes
(1596-1650)
• Let A1, A2, …, An be any sets, where n ℤ+ and n 3.
• Cartesian product of n sets A1, A2, …, An is defined as follows:
A1 A2 … An def {(a1, a2, …, an) | ai Ai, 1 i n}.
47
Relations
• Ordered pair
• Cartesian product
• Binary relation
• Relation representation
• Properties of relations
48
Binary Relation
• Definition (binary relation): Let A and B be sets. A binary relation from a
set A to a set B is a set of ordered pairs (a, b) where a is an element of A
and b is an element of B.
• A binary relation from A to B is a subset R A B
• A relation on a set A is a relation from A to A, i.e., a subset R A A
• Notation: When an ordered pair (a, b) is in a relation R, we write a R b, or
(a, b) R. It means that element a is related to element b in relation R. We
will write aR b when a element a is not related to element b in relation R.
49
Binary Relation
Example:
Let A be the students in a the CS major
A = {Tan, Bob, Michel, Amy}
Let B be the courses the department offers
B = {CS101, CS201, CS202}
We specify relation R = A B as the set that lists all students a A
enrolled in class b B
R = { (Tan, CS101), (Bob, CS201), (Bob, CS202),
(Amy, CS201), (Amy, CS202) }
50
Representing relations
Tan Tan X
Bob X X
CS101
Bob Michel
Amy X X
CS201
Michel
CS202
Amy
Relations on a Set
• A relation on a set A is a relation from A to A.
52
Relations on a Set
Consider the following relations on Z:
• R1 = {(a, b) | a b} (1,1) (1,2) (2,1) (1,-1) (2,2)
• R2 = {(a, b) | a > b} R1
• R3 = {(a, b) | a = b or a = -b} R2
• R4 = {(a, b) | a = b}
R3
• R5 = {(a, b) | a = b+1}
R4
• R6 = {(a, b) | a + b 3}
R5
R6
53
Properties of Binary Relations
• A binary relation R A x A is called
• Reflexive iff (x,x) R
• Symmetric iff (x,y) R → (y,x) R
• Antisymmetric iff ((x,y) R (y,x) R) → x = y
• Transitive iff (x,y) R and (y,z) R → (x,z) R
• A binary relation is called equivalence relation iff it is reflexive, symmetric,
and transitive
54
Contents
• Definitions
• Set operations
• The algebra of sets
• Relations
• Functions
55
Functions
• Definitions
• Properties of function
• Injective, surjective and bijective function
• Function representation
56
Functions
Definition: A function f from a set A to a set B, denote it by f: A→B, is a
relation from A to B that satisfies:
for each element a in A, there is an element b in B such that (a, b) is in the
relation, and
if (a, b) and (a, c) are in the relation, then b = c. ➔ 1 to 1:
For every input there is exactly one output.
A function is also called a mapping or a transformation.
57
Functions
• Definition: A function f from a set A to a set B, denote it by f: A→B, is a
relation from A to B that satisfies:
• for each element a in A, there is an element b in B such that (a, b) is in
the relation, and
• if (a, b) and (a, c) are in the relation, then b = c.
• A function is also called a mapping or a transformation. ➔ 1 to 1
• The set A in the above definition is called the domain of the function and B
its codomain.
• Question: Let A and B be two sets in which |A| = m, |B| = n. The statement
“the number of possible functions from A to B is nm” is TRUE or FALSE?
58
Functions
• The image of the set S under function f : A→B, denoted by f(S) is:
f(S) = { f(a) | a S }
• The image of the domain under function f : A→B, denoted by range f is:
range f = f(A)
(is also called the range of f )
• In general case: range f = f(A) B.
59
Example: Are the following relations also functions?
0
0
-4 -4
-2
-2
5 5
3
3
8 8
-7
-7
FUNCTION NOT A
FUNCTION
Functions
• Definitions
• Properties of function
• Injective, surjective and bijective function
• Function representation
61
Properties of function
f: A→B is a function from a set A to a set B, S ⊆ A, and T ⊆ A.
Statement f( S ∪ T ) = f(S) ∪ f(T) is TRUE or FALSE ?
→ Proof ?
62
Properties of function
f: A→B is a function from a set A to a set B, S ⊆ A, and T ⊆ A.
Statement f( S ∩ T ) ⊆ f(S) ∩ f(T) is TRUE or FALSE?
→ Proof ?
63
Functions
• Definitions
• Properties of function
• Injective, surjective and bijective function
• Function representation
64
Injective, surjective and bijective function
A function f from a set A to a set B is said to be injective (one-to-one) if and
only if:
for all elements a1, a2 A
if f (a1) = f (a2) then a1 = a2 no two inputs have the same output.
≤ 1 arrow in
f( ) =
A B
|A| ≤ |B|
Injective, surjective and bijective function
A function f from a set A to a set B is said to be surjective (onto), if and only if:
bB, aA: b = f(a) .
1 arrow in
f( ) =
A B
|A| ≥ |B|
Injective, surjective and bijective function
A function is called a bijection, if it is injective (1-1) and surjective (onto).
69
Bijection
f( ) =
A B
|A| = |B|
Injective, surjective and bijective function
A function is called a bijection, if it is injective (1-1) and surjective (onto).
Examples:
1) Linear functions: f(x)=ax+b when a0
(with domain and co-domain R)
2) Exponential functions: f(x)=bx (b>0, b1)
(with domain R and co-domain R+)
3) Logarithmic functions: f(x)=logbx (b>0, b1)
(with domain R+ and co-domain R)
71
Functions
• Definitions
• Properties of function
• Injective, surjective and bijective function
• Function representation
72
Function representation
Functions can be represented four different ways:
mapping
1. ______________
graph
2. ______________
table
3. ______________
matrix
4. ______________