0% found this document useful (0 votes)
25 views22 pages

Week 3 Notes

Uploaded by

Anis Safwan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views22 pages

Week 3 Notes

Uploaded by

Anis Safwan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

AUTOMATA THEORY AND

COMPUTATION (ICS3253)
Week 3 – Introduction #2
CLASS 2
RELATIONS AND FUNCTIONS 2

 Definition of Relation: A relation on sets S and T is a set of ordered pairs (s,t),


where

 S and T need not be different


 The set of all first elements is the domain of the relation, and
 The set of all second elements is the range of the relation
>>> EXAMPLE 3

 Sets S and T are disjoint


 Set S = {a,b,c,d,e}
 Set T = {w,x,y,z}

 Then, a relation on S and T is


R={(a,y),(c,w),(c,z),(d,y)}
>>> REPRESENTATION 4
FUNCTIONS 5
 Suppose every element of S occurs exactly once as the first element of an
ordered pair
 Every element of S has exactly one arrow arising from it – this relation is a
function
FUNCTIONS AS RELATIONS AND KINDS OF FUNCTIONS 6

 A function is a relation from A to B, i.e., a subset of A x B, such that each


belongs to a unique ordered pair (a,b) in f
 Functions are:
 One-to-one (Injection): if different elements in domain have distinct images in
the range - implies
 Onto (Surjection): if each element of the range is the image of some element of
A
 One-to-one onto (Bijection): both one-to-one and onto
 Invertible: inverse relation is a function from B to A
 a function is invertible if and only if it is both one-to-one and onto
QUESTIONS AND SOLUTIONS 7

 Q: Find whether from the set of integers to the set of integers is one-to-one
 Solution: The function is not one-to-one as, for example f(1)=f(-1)=1 but 1 -1
 Q: Given f is a function where A={a,b,c,d} and B={1,2,3} with f(a)=3, f(b)=2,
f(c)=1 and f(d)=3. Is the function f an onto function?
 Solution: Hint: draw the oval, map the elements
 in this case you will see that all three elements of the codomain (range) are
images of elements in the domain, therefore, we have f as on “onto” function
>>> COMPOSITION OF FUNCTION 8

 Given f(x) = 2x+3 and g(x)=3x+2, check if commutative law holds good for
composition of functions
>>> 9

 Check whether the mapping f: where defined by is one to one and onto
 Solution: x=set of all non-zero real numbers. Let . Then
 Hence, f is one to one
 For every non-zero real number there exists a non-zero real number such that
 Hence, every element is an image of . Therefore f is onto. Therefore f is one-
to-one and onto
GRAPHS AND TREES 10

 A graph G consists of a finite set V of objects (vertices) – a finite set E of


objects (edges), and a function that assigns to each edge of a subset {v, w},
where v and w are vertices (and may be the same)
 Thus, we write
>>> 11

 Given V={1,2,3,4} and E={e1, e2, e3, e4, e5}


 is defined by ()= ()={1,2 } | ()={4,3} | ()={1,3} and ()={2,4}
 Then, G(V,E, ) is a graph as shown here:
>>> 12
 Degree of a vertex: Number of edges having that vertex as an end point
 Loop: A graph may have an edge from a vertex to itself, such an edge is called a loop
 Isolated vertex: A vertex with zero as degree is called an isolated vertex
 Adjacent vertices: A pair of vertices that determine an edge are adjacent vertices
 Path: A path in a graph G consists of a pair (V, E) of sequences
 Circuit: A path that begins and ends at the same vertex
 Simple Path: A path is called simple if no vertex appears more than once in the vertex
sequence
 Connected Graph: Connected if there is a path from any vertex in the graph, the graph is
disconnected
 Components: If graph is disconnected, the various connected pieces are called the
components of the graph
>>> 13
 In the graph below, ‘e’ is isolated, vertices ‘a’ and ‘b’ are adjacent, vertices ‘a’
and ‘d’ are not adjacent
>>> 14

 Connected graphs:
>>> 15

 Disconnected graphs:
>>> 16

 A walk is a sequence of edges, where the finish vertex of each edge is the start
vertex of the next edge
 Tree: A graph if it is connected and has no simple cycle
 A path is a cycle if it starts and ends in the same node – a simple cycle is one
that does not repeat any nodes except for the first and last
 Directed graph: A graph that has arrows instead of lines
 Outdegree: The number of arrows pointing from a particular node is
outdegree of that node
 Indegree: The number of arrows pointing to a particular node
STRINGS AND LANGUAGES 17
 Alphabet: Defined as a finite set of symbols
 Roman Alphabet: {a,b,c, … , z}
 Binary Alphabet: {0,1}
 String: A string over an alphabet is a finite sequence of symbols from that
alphabet, which is usually written next to one another and not separated by
commas
 If = {0,1}, then 001001 is a string over
 If = {a,b,c,…,z} then axyrpqstcd is a string over
 Length of String: Length as a sequence, written as |w|
 |100010| = 6
 Empty string: String with zero length
>>> 18

 Reverse String: if w=w1w2…wn where each wi , the reverse of w is wnwn-1…w1


 Substring: z is a substring of w if z appears consecutively within w
 deck is a substring of abcdeckabcjkl
 Concatenation: Assume a string x of length m and string y of length n, the
concatenation of x and y is written xy which is the string obtained by
appending y to the end of x
 Concatenating string to itself many times, use the superscript notation
 xxxxx…x = xk (where k is the length)
 Suffix: If w = xv for some x, then v is a suffix of w
 Prefix: If w = vy for some y, then v is a prefix of w
>>> 19

 Lexicographic ordering: The same as the dictionary ordering, except that


shorter strings precede longer strings
 {0,1} is (, 0, 1, 00, 01, 10, 11, 000, 001 …}
 Language: Any set of string over an alphabet is a language
 Infinite languages L is denoted as L = {w * : w has property P}
 L1 = {w {0,1}* : w has an equal number of 0s and 1s}
 L2 = {w * : w=wR} where wR is the reverse string of w
QUESTIONS AND SOLUTIONS 20

 Given = {a,b}, obtain *


 Give an example of a finite language in
 Given L={anbn : n0}, check if the strings aabb, aaaabbbb, abb are in the language L
 Solution:
 * = {, a, b, aa, ab, ba, bb, aaa, bbb …}
 aabb is a string in L
 aaaabbbb is a string in L
 However, abb is not a string in L
QUESTIONS 21

 Let L = {ab, aa, baa}. Which of the following strings are in L*?
 abaabaaabaa
 aaaabaaaa
 baaaaabaaaab
 baaaaabaa
 baaaaabaaaaabbb
 babaaaabaaaab
ENOUGH?
See you next week

You might also like