Sunteți pe pagina 1din 42

Theory of Automata

LECTURE 06
Finite Automaton
Example: Consider the language L of strings, defined over Σ={a, b}, starting
with b. The language L may be expressed by RE b(a + b)* , may be accepted by
the following FA
Finite Automaton
Example:
Consider the language L of strings, defined over Σ={a, b}, ending in
a. The language L may be expressed by RE
(a+b)*a
This language may be accepted by the following FA
Example Continued …

There may be another FA corresponding to the given language.


Example continued …
Note

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.
Note
It is to be noted that given the languages L1 and L2 ,where
L1 = The language of strings, defined over Σ={a, b}, beginning with a
L2 = The language of strings, defined over Σ={a, b}, not beginning with b
The  does not belong to L1 while it does belong to L2 . This fact may be depicted
by the corresponding transition diagrams of L1 and L2.
FA1 Corresponding to L1

The language L1 may be expressed by the regular expression a(a + b)*


FA2 Corresponding to L2

The language L2 may be expressed by the regular expression a


(a + b)* + Λ
Example
Consider the Language L of Strings of length two or more, defined over
Σ = {a, b}, beginning with and ending in same letters.
The language L may be expressed by the following regular expression
a (a + b)* a + b (a + b)* b
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.
This language L may be accepted by the following FA
Example Continued …
Example
An FA accepting the Language L of Strings, defined over Σ = {a,
b}, beginning with and ending in same letters.
Solution:The language L may be expressed by the following
regular expression
(a+b)+a(a + b)*a + b(a + b)*b
This language L may be accepted by the following FA
Solution continued …
Example
Consider the Language L of Strings , defined over Σ = {a, b},
beginning with and ending in different letters.
The language L may be expressed by the following regular expression
a (a + b)* b + b (a + b)* a
This language may be accepted by the following FA
Example Continued …
Example
Consider the Language L , defined over Σ = {a, b} of all strings
including Λ, The language L may be accepted by the following FA
a,b

a,b
1  2+

The language L may also be accepted by the following FA


Example Continued …
a,b

The language L may be expressed by the following regular expression

(a + b)*
Example
Consider the Language L , defined over Σ = {a, b} of all non empty strings. The language
L may be accepted by the following FA

a,b

a,b
– +

The above language may be expressed by the following regular expression (a + b)+
Example
Consider the following FA, defined over Σ = {a, b}
a,b

a,b
– +

It is to be noted that the above FA does not accept any string. Even it
does not accept the null string. As there is no path starting from initial
state and ending in final state.
Equivalent FAs

It is to be noted that two FAs are said to be equivalent, if


they accept the same language, as shown in the following
FAs.
Equivalent FAs Continued …
a,b

FA1 a,b
– +
a,b
FA2
a,b
1 – 2

FA3 a,b a,b

1– a,b 2 3+
Note (Equivalent FAs)
In FA1, there is no path starting from initial state and ending in final
state, while in FA2, there is no final state and in FA3, there is a final
state but FA3 is disconnected as the states 2 and 3 are disconnected.
It may also be noted that the language of strings accepted by FA1,
FA2 and FA3 is denoted by the empty set i.e.
{ } OR Ø
Example
Consider the Language L of strings , defined over Σ = {a, b},
containing double a.
The language L may be expressed by the following regular
expression
(a+b)* (aa) (a+b)*.
This language may be accepted by the following FA
Example Continued …

b a,b
a
2
a 3+
1-

b
Example
Consider the language L of strings, defined over
Σ={0, 1}, having double 0’s or double 1’s, The language L may
be expressed by the regular expression
(0+1)* (00 + 11) (0+1)*
This language may be accepted by the following FA
Example Continued …
x

0
0
0,1

- 0 1 +

1
1

y
Example
Consider the language L of strings, defined over Σ={a, b}, having
triple a’s or triple b’s. The language L may be expressed by RE

(a+b)* (aaa + bbb) (a+b)*


This language may be accepted by the following FA
Example Continued …
2 a 4

a
a b a,b

1–– a b 6+

b a b

b 5
3
Example
Consider the EVEN-EVEN language, defined over Σ={a, b}. As
discussed earlier that EVEN-EVEN language can be
expressed by the regular expression
(aa+bb+(ab+ba)(aa+bb)*(ab+ba))*
EVEN-EVEN language may be accepted by the following FA
Example Continued …
b
1 3
b

a a a a

b
2 4
b
FA corresponding to finite languages
Example
Consider the language
L = {Λ, b, ab, bb}, defined over
Σ ={a, b}, expressed by Λ + b + ab + bb OR Λ + (Λ + a + b) b.
The language L may be accepted by the following FA
a,b
y

Example continued … a
a,b

a b
1  3
4 +
b
b
2 + 5 +

a,b
a

a,b
Example Continued …
It is to be noted that the states x and y are called Dead States, Waste
Baskets , as the moment one enters these states there is no way to
leave it.
 What is Davey John Lockers?
Note
It is to be noted that to build an FA accepting the language having
less number of strings, the tree structure may also help in this
regard, which can be observed in the following transition diagram for
the Language L, discussed in the previous example
4
a

3 a,b
b
a a,b
5+ a,b
1± 8
a,b
b
a
6

2+ a,b
b
7+
Example
Consider the language
L = {aa, bab, aabb, bbba}, defined over
Σ ={a, b}, expressed by aa + bab + aabb + bbba OR aa (Λ + bb) + b (ab + bba)
The above language may be accepted by the following FA
a,b
Example Continued … x

b a,b
a a

a a b b
1– 2 3+
4 5+
b

6 b 7 b a
8 9+
a
a b
10 a,b
a
b
a,b
11+ y
a,b
Example
Consider the language L = {w belongs to {a,b}*: length(w) >= 2 and w neither
ends in aa nor bb}.
The language L may be expressed by the regular expression
(a+b)*(ab+ba)
This language may be accepted by the following FA
Example Continued …

2
b 4+
a
a b
1– b a
b
b
3 a 5+
Note
It is to be noted that building an FA corresponding to the language L,
discussed in the previous example, seems to be quite difficult, but
the same can be done using tree structure along with the technique
discussed in the book
Introduction to Languages and Theory of Computation, by J. C.
Martin
Defining Languages (continued)…
Transition Graph
Definition: A Transition graph (TG), is a
collection of the followings
1)Finite number of states, at least one of which is start state and
some (maybe none) final states.
2)Finite set of input letters (Σ) from which input strings are
formed.
3)Finite set of transitions that show how to go from one state to
another based on reading specified substrings of input letters,
possibly even the null string Λ.
Quiz

S-ar putea să vă placă și