CSC 413
Discrete Mathematics II
Course Instructors:
Dr. Victor T. Odumuyiwa
Dr. Ufuoma C. Ogude
Department of Computer Sciences
University of Lagos
•Lectures:
– E 304, Wednesday 10:00 am to 11:00 am
– E 304, Thursday 8:00 am to 10:00 am
Goal of CSC 413
The goal of this course is to introduce students to a range of
mathematical tools and skills from discrete mathematics that are
widely used in Computer Sciences and Engineering.
All CSC majors should take this course.
Mathematical tools:
logic, sets, functions, relations, counting, graph theory etc
Mathematical skills:
emphasis on modeling, logic, efficiency
Course Outline
We study topics in such areas as:
Sets and logic
proof techniques
relations and functions,
counting and combinatorics,
discrete probability,
graphs and trees and
NP-Completeness.
Course Material
Textbook
Discrete Mathematics
and Its Applications
by Kenneth H. Rosen
Use lecture notes as study guide.
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
Emphasizes the new role of mathematics
The new role of Mathematics
Make the computer to solve the problem for you
Modeling (vs. calculations)
Using logic
» to choose the right model
» to write a correct computer program
» to justify answers
Efficiency
» make the computer to solve the problem fast
» choose the more efficient model
Presentation Outlines
Relation and Functions:
Definition, representation, relation on a set
Properties:
Reflexivity, symmetry, antisymmetric, irreflexive, asymmetric
Combining relations:
, , \, composite of relations
Representing relations:
0-1 matrices, directed graphs
n-ary Relations & their Applications
Relations
A "relation" is just a relationship between sets of information.
In math a "relation" is a connection between a set of inputs ( domain) and a
set of outputs (range).
The domain is the set of all x values in the relation
The range is the set of all y values in the relation
Relationships between elements of sets are represented using the
structure called a relation.
The most direct way to express a relationship between elements of
two sets is to use ordered pairs made up of two related elements:
(-3, -2), (5, 0), (0, 1), (-1, 4), (4, 5), (2, -5)
Definition
A relation between elements of two sets is a subset of their
Cartesian products (set of all ordered pairs) i.e. R AB
Let A and B be sets. A binary relation from A to B is a subset
of A * B.
A binary relation from a set A to a set B is a subset i.e. R AB
={ (a,b) | aA, bB}
In other words, a binary relation from A to B is a set R of ordered
pairs where the first element of each ordered pair comes from A and
the second element comes from B.
That is, for a binary relation R we have R AB.
Relations
We use the notation aRb to denote that (a, b)R and aRb
to denote that (a, b)R.
• When (a,b)R (i.e. (a,b) belongs to R), we say that a is related to
b by R.
• Notation: aRb, aRb or aRb
aRb (a, b) R
aRb (a, b) R
Likewise, n-ary relations express relationships among n
elements
• Let A1, A2, …, An be sets. An n-ary relation of these sets is a
subset of A1×A2×…×An.
The sets A1, A2, ..., An are called the domains of the relation, and
n is called its degree.
The elements of A1A2…An are ordered n-tuples.
Exercises
A binary relation from set A to B is a subset of
Cartesian product A B
Example1: A {0,1,2} B {a, b}
A Relation: R {(0, a ), (0, b), (1, a ), (2, b)}
Example2:
Let A={0, 1, 2} and B={a, b}.
Then {(0, a), (0, b), (1, a), (2, b)} is a relation from A
to B. That is, 0Ra but not 1Rb
0 R a b
a
0 X X
1
1 X
b
2 X
2
Relations
When (a, b) belongs to R, a is said to be related to b by R.
Example3:
Let P be a set of people, C be a set of cars, and D be the
relation describing which person drives which car(s).
P = {Tunde, Philip, Bello, Emeka},
C = {Mercedes, BMW, tricycle}
D = {(Tunde, Mercedes), (Philip, Mercedes),
(Philip, BMW), (Bello, tricycle)}
This means that Tunde drives a Mercedes, Philip drives a
Mercedes and a BMW, Bello drives a tricycle, and Emeka does
not drive any of these vehicles.
Representation
To represent a relation, we can enumerate every element of R
Example
Let A = {a1,a2,a3,a4,a5} and B = {b1,b2,b3}
Let R be a relation from A to B defined as follows
R = {(a1,b1),(a1,b2),(a1,b3),(a3,b1),(a3,b2),(a3,b3),(a5,b1)}
We can represent this relation Graphically
A a1 b1 B
a2 b2
a3 b3
a4
a5
Representations (other than equations)
Table:
x -3 -1 0 2 4 5
y -2 4 1 -5 5 0
Graph:
(-3, -2)
(5, 0)
(0, 1)
(-1, 4)
(4, 5)
(2, -5)
Representations (other than equations)
Mapping
(-3, -2), (5, 0), (0, 1), (-1, 4), (4, 5), (2, -5)
-3 -1 0 2 4 5
-5 -2 0 1 4 5
Representations (other than equations)
Mapping (another way)
(-3, -2), (5, 0), (0, 1), (-1, 4), (4, 5), (2, -5)
-3 -5
-1 -2
0 0
2 1
4 4
5 5
Exercise
A = set of all cities
B = set of the 36 states in Nigeria
Define the relation R by specifying that (a, b) belongs
to R if city a is in state b.
Functions
Definition:
A function or mapping (Defined as f: X →Y) is a
relationship from elements of one set X to elements of
another set Y (X and Y are non-empty sets).
X is called Domain and Y is called Codomain of function ‘f’.
We write f: X→Y. Alternatively we write f(x)=y.
“a function is…a relation in which every input is paired with
exactly one output”
Definition:
a function f is a rule which assigns to each member x of a set X a
unique member y of set Y.
A function can be One-To-One, ONTO and INVERTIBLE Functions
A function f: X→Y is said to be invertible if there exists a function
g: Y→X
For a function f the following statements are equivalent f(x)=y, xfy,
(x,y)∈f.
Functions as Relations
A “function” is a well-behaved relation, that is, given a starting point
we know exactly where to go.
Note the difference between a relation and a function:
In a relation, each a ∈ A can map to multiple elements in B.
Relations are generalizations of functions.
Thus, for each element a of A an element b exists in B but not vice-
versa.
• Not every relation is a function.
• Every function is a relation.
Functions find their application in various fields like
representation of the computational complexity of algorithms,
counting objects, study of sequences and strings, to name a few.
Functions as relations
Recall relation is a subset of AxB (Let A and B be two nonempty sets.)
Hence a function f from a set A to a set B assigns exactly one element
of B to each element of A
A function represents a relation where exactly one element of B is
related to each element of A
Function ‘f’ is a relation on X and Y s.t for each x ∈ X, there exists a
unique y ∈ Y such that (x,y) ∈ R. x is called pre-image and y is called
image of function f.
You might remember that a function f from a set A to a set B assigns a unique element of B to each
element of A. The graph of f is the set of ordered pairs (a, b) such that b = f(a).
Since the graph of f is a subset of AB, it is a relation from A to B.
Moreover, for each element a of A, there is exactly one ordered pair in the graph that has a as its
first element. Conversely, if R is a relation from A to B such that every element in A is the first
element of exactly one ordered pair of R, then a function can be defined with R as its graph.
This is done by assigning to an element aA the unique element bB such that (a, b)R.
Relations on a Set
Definition:
A relation on the set A is a relation from A to A and is a
subset of AA.
In other words, a relation on the set A is a relation from A
to A, i.e., a subset of A x A
Example1:
A relation on set A {1,2,3,4}
Solution:
R {(1,1), (1,2), (2,1), (2,2), (3,4), (4,1), (4,4)}
Example2:
Let A be the set {1, 2, 3, 4}. Which ordered pairs are in the
relation R = {(a,b)|a divides b}?
Solution:
Since (a, b) is in R if and only if a and b are positive integers
not exceeding 4 such that a divides b
R={(1,1),(1,2),(1,3),(1,4),(2,2),(2,4),(3,3),(4,4)}
1 1 R 1 2 3 4
2 2 1 X X X X
3 3 2 X X
3 X
4 4
4 X
Exercise2
Consider these relations on set of integers
R1={(a,b)|a≤b}
R2={(a,b)|a>b}
R3={(a,b)|a=b or a=-b}
R4={(a,b)|a=b}
R5={(a,b)|a=b+1}
R6={(a,b)|a+b≤3}
Which of these relations contain each of the pairs
(1,1), (1,2), (2,1), (1, -1) and (2, 2)?
Example3
How many different relations can we define on a set A
with n elements?/How many relations are there on a set
with n elements?
A relation on a set A is a subset of AA. How many elements are in AA ?
There are n2 elements in AA, so how many subsets (= relations on A) does
AA have?
The number of subsets that we can form out of a set with m elements is
2m. Therefore, 2n2 subsets can be formed out of AA.
Solution: We can define 2n2 different relations on A.
Note:
As A x A has n2 elements, there are subsets 2
2n
Thus there are relations
n 2
on a set with n elements
2
That is, there are 3 2
relations on the set {a, b, c}
9
2 2 512
Assignment
Define with detailed example the following
functions:
1.One-To-One,
2.ONTO and
3.INVERTIBLE