Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
11 views

Relations and Functions

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Relations and Functions

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

AUTOMATA THEORY AND FORMAL LANGUAGES

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}

R = {(1,1), (1,2), (2,1), (2,2), (3,4), (3,3), (4,3), (4,4)} → reflexive


R = {(1,1), (1,2), (2,1), (2,2), (3,4), (4,3), (4,4)} → symmetric
R = {(1,1), (1,2), (2,3), (3,4), (1,3), (4,4)} → transitive
REPRESENTATION OF RELATIONS
❑Relation as arrow diagram
Example: A B

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

Alternatively, f is bijective if it is a one-to-one


correspondence between those sets, in other
words both injective and surjective.
FUNCTIONS
• Constant function (mapped to the same single
element of B). With a constant function, for any two
points in the interval, a change in x results in a zero
change in f(x).
• Identity (mapped into itself)
FUNCTIONS
• Invertible function

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.

•Trees are undirected graphs. Any two vertices are


connected by exactly one simple path. A tree also does
not contain a cycle.
GRAPHS
• A simple graph G = (V,E)
V= {set of all vertices} –not empty
E = {set of all edges} –not empty
E = {subsets of V with cardinality 2}

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}

Then G=(V, E, γ) is a graph shown:


GRAPHS
ADJACENT VERTICES a pair of vertices that determine an
edge are “adjacent” vertices.
In the graph, vertex ‘e’ is an “isolated vertex”, ‘a’ and ‘b’ are
adjacent vertex ‘a’ and ‘d’ are not adjacent.
GRAPHS
Path in a graph G consists of a pair (V, E) of sequences.

Circuit is a path that begins and ends at the same vertex.


GRAPHS
Simple path. A path is called “simple” if no vertex
appears more than once in the vertex sequence.
GRAPHS
Connected Graph. A graph is called “connected” if
there is a path from any vertex to any other vertex in the
graph, otherwise, the graph is “disconnected”.

a b a b

c c

d e d e

Connected graph Disconnected graph


GRAPHS
Component. If the graph is disconnected, the various
connected pieces are called the components of the graph.

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.

You might also like