Lecture 7
Lecture 7
► Regular Expressions
► Finite Automata
Definition:
► A Finite automaton (FA), is a collection of the followings:
► Finite number of states, having one initial and some (maybe none) final states.
► Finite set of input letters (Σ) from which input strings are formed.
► Finite set of transitions i.e. for each state and for each input letter there is a
transition showing how to move from one state to another.
► Σ = {a,b}
► States: x, y, z where x is an initial state and z is final state.
► Transitions:
► At state x reading a go to state z,
► At state x reading b go to state y,
► At state y reading a, b go to state y
► At state z reading a, b go to state z
► It may be noted that the information of an FA, given in the previous table, can also
be depicted by the following diagram, called the transition diagram, of the given
FA
a,b
y
b
a,b
x– a
Z+
Lahore Garrison University
10
Cont..
► It may be noted that to indicate the initial state, an arrow head can also be placed before
that state and that the final state with double circle, as shown below. It is also to be
noted that while expressing an FA by its transition diagram, the labels of states are not
necessary.
a, b
a, b
► Σ = {a,b}
States: x, y, where x is both initial and final state.
Transitions:
1. At state x reading a or b go to state y.
2. At state y reading a or b go to state x.
► It may be noted that the previous transition table may be depicted by the
following transition diagram.
► Build an FA for the language L of strings, defined over Σ={a, b}, of odd length
a, b
– +
a,b
► Consider the language L of strings, defined over Σ={a, b}, starting with b, may be
accepted by the following FA
► Consider the language L of strings, defined over Σ={a, b}, ending in a. This language
may be accepted by the following FA
a
a
– +
a b
b
► It may be noted that corresponding to a given language there may be more than one
FA accepting that language, but for a given FA there is a unique language accepted by
that FA.
a,b
–
a +
a,b
b
*
► The language L1 may be expressed by the regular expression a(a + b)
a,b
± a +
b a,b
*
► The language L2 may be expressed by the regular expression a (a + b) + Λ
► Consider the Language L of Strings of length two or more, defined over Σ = {a, b},
beginning with and ending in same letters.
b a a
+
a b
–
a b
b
b
+
a
► It is to be noted that if the condition on the length of string is not imposed in the
above language then the strings a and b will then belong to the language
► Build an FA accepting the Language L of Strings, defined over Σ = {a, b}, beginning
with and ending in same letters
Q&A