Relations and Functions
Relations and Functions
Introduction to the
Theory of Computation
(B) Relations and Functions
OBJECTIVE
■At the end of the submodule, the learner should be able
to:
- Recall concepts of relations and functions
RELATIONS
A relation on sets S and T is a set of ordered pairs (s, t),
where:
(a) s ∈ S (s is a member of S )
(b) t ∈ T
(c) S and T need not be different
(d) The set of all first elements is the “domain” of the relation,
and
(e) The set of all second elements is the “range” of the relation.
RELATIONS
Then a relation on S and T is
R = {(a, y), (c, w), (c, z), (d, y)}
Example:
Let A = { 1, 2, 3, 4 } and B = { 1, 2, 3, 4}
where R is a relation from A to B defined by a|b, “a
divides b”, (a, b) R.
R = { (1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4) }
Dom(R) = { 1, 1, 1, 1, 2, 2, 3, 4 } → Domain
Ran(R) = { 1, 2, 3, 4, 2, 4, 3, 4} → Range
RELATIONS
Let A = { 1, 2, 3}:
R1 = { (a, b) | (a < b)} = { (1, 2), (1, 3) (2, 3) }
R2 = { (a, b) | a = b } = { (1, 1), (2, 2), (3, 3) }
R3 = { (a, b) | b = 4a} = { }
R4 = { (1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (31), (3,2),(3,3)}
Note:
R2 is called identity relation
R3 is called void relation
R4 is called universal relation
RELATIONS
Equivalence Relation
A subset R of A. A is called an equivalence relation on A if R satisfies
the following conditions:
(i) (a, a) ∈ R for all a ∈ A (R is reflexive)
(ii) If (a, b) ∈ R, then (b, a) ∈ R, then (a, b) ∈ R (R is symmetric)
(iii) If (a, b) ∈ R and (b, c) ∈ R, then (a, c) ∈ R (R is transitive)
RELATIONS
Let A = {1,2,3,4}
A = {1, 2, 3, 4} 1 a
B={a, b, c} 2 b
3 c
R={(1, b), (1, c), (3, b), (4, a), (4, c)} 4
REPRESENTATION OF RELATIONS
❑Relation as table
A\B a b c
Example:
1 (1, b) (1, c)
2
A = {1, 2, 3, 4} 3 (3, b)
B={a, b, c} 4 (4, a) (4, c)
R={(1, b), (1, c), (3, b), (4, a), (4, c)}
REPRESENTATION OF RELATIONS
❑Relation as matrix
Example: 0 1 1
0 0 0
0 1 0
A = {1, 2, 3, 4}
1 0 1
B={a, b, c}
R={(1, b), (1, c), (3, b), (4, a), (4, c)}
REPRESENTATION OF RELATIONS
❑Relation as directed graph
Example:
A = {1, 2, 3, 4}
R= { (1, 1), (1, 2), (2, 1), (2, 2), (3, 2),
(3, 4), (4, 3), (4, 4) }
FUNCTIONS
• A function is a way of matching the members of a set
"A" to a set "B":
• Each element of A should be associated to exactly one
element of B, though more A may be associated in B.
• Every element of A must be associated with unique
element of B.
• May be some elements of set B which are not assigned
to any element of set A.
FUNCTIONS
• Every function is a relation.
• Not all relations are functions.
FUNCTIONS
• One-to-one (injective) correspondence –
function
FUNCTIONS
• Onto (surjective) –if each element of B is f image
of at least one element of A f(a)=b
FUNCTIONS
• Into function (if there is one element of B which is not
f image of any element of A)
FUNCTIONS
Bijective - A function f (from set A to B) is
bijective if, for every y in B, there is exactly one
x in A such that f(x) = y
A = (a,b,c,d,e}
B = {-36,9,-4,49,25}
Invertible function
FUNCTIONS
• Inclusion function. A function whose
domain is a subset of its codomain, and
for which all the elements in its domain
are fixed points.
AUTOMATA THEORY AND FORMAL LANGUAGES
Introduction to the
Theory of Computation
(C ) Graphs and Trees
OBJECTIVE
■At the end of the submodule, the learner should be able
to:
- Recall concepts of graphs and trees
GRAPHS AND TREES
A Graph is a bunch of vertices (Nodes) which are
represented by circles and are connected by edges
represented by lines.
DIGRAPH
–In-degree
–Out-degree
GRAPHS
Example:
Given V= {1, 2, 3, 4} and E={e1,e2,e3,e4,e5)
γ is defined by:
γ(e1) = γ(e5) = {1,2} γ(e2) = {4,3}
γ(e3) ={1,3} γ(e4) = {2,4}
a b a b
c c
d e d e
a b
d e
TREE
• A Graph is said to be a Tree if it is connected and
has no simple cycles.
TREE
• Simple cycle is one that does not repeat any node
except for the first and last.