Download as pps, pdf, or txt
Download as pps, pdf, or txt
You are on page 1of 21

Lecture # 15 Recap Lecture 14

• Kleene’s theorem part III (method 2:


Concatenation of FAs) continued, Kleene’s
theorem part III (method 3:closure of an FA),
Examples
Task

Build FA corresponding to the concatenation of these


two FAs i.e. FA1FA2 where a,b

FA1 x1 - a,b
x2 b
x3 +
a

x4 a,b

b a b
FA2 y1 - y 2+
a
Task solution

• RE corresponding to FA1 may be


(a+b)b(a+b)* with b as second letter
• RE corresponding to FA2 may be
(a+b)b(a+b)* b*a(b+ab*a)* with odd
number of a’s
Solution continued … a,b

x1 - a,b
x2 b
x3 +
a

x4 a,b

b a b
y1 - y 2+
a

New States after reading


Old States
a b

z-x x z x z
Solution continued …

New States after reading


Old States
a b

z 2  x2 x4  z 3 (x3,y1)  z4
z 3  x4 x4  z 3 x4  z3
z4  (x3,y1) (x3 ,y1,y2)  z5 (x3,y1)  z4
z5+  (x3,y1 ,y2) (x3 ,y1 ,y2)  z5 (x3,y1 ,y2)  z5
Solution continued …

b a,b

z4 a z+5
b
- z1 a,b z2 a,b
a

z3
Note

• It is to be noted that as observed in the


previous examples, if at the initial state of the
given FA, there is either a loop or an
incoming transition edge, the initial state
corresponds to the final state and a non-final
state as well, of the required FA, otherwise
the initial state of given FA will only
correspond to a single state of the required
FA (i.e. the initial state which is final as well).
Task

• Build an FA corresponding to the closure


of the following FA

b
b a

y1 ± y2
a
Nondeterministic Finite
Automaton (NFA)
Definition: An NFA is a TG with a unique start state
and a property of having single letter as label of
transitions. An NFA is a collection of three things
1) Finite many states with one initial and some final
states
2) Finite set of input letters, say, ={a, b, c}
3) Finite set of transitions, showing where to move
if a letter is input at certain state ( is not a valid
transition), there may be more than one transition
for certain letters and there may not be any
transition for certain letters.
Observations

It may be observed, from the definition of NFA,


that the string is supposed to be accepted, if there
exists at least one successful path, otherwise
rejected.
It is to be noted that an NFA can be considered to
be an intermediate structure between FA and TG.
The examples of NFAs can be found in the
following
Example

2+
a

1- a
3

a
b
4 5+

It is to be noted that the above NFA accepts


the language consisting of a and ab.
Example

a, b a,b

a a
1- 2 3+

It is to be noted that the above NFA accepts


the language of strings, defined over
Σ = {a, b}, containing aa.
Note

• It is to be noted that NFA helps to eliminate a


loop at certain state of an FA. This process is
done converting the loop into a circuit. But
during this process the FA remains no longer
FA and is converted to a corresponding NFA,
which is shown in the following example.
Example

• Consider a part of the following FA with an


alphabet Σ={a,b,c,d}
… 4 8 …
a a b

… 5 b c 9
7 …
c d
… 6 10 …
To eliminate the loop at state 7, the corresponding
NFA may be as follows
Example continued ...

… 4 b …
11 8
a c
d
… 5 a a …
9
b b
c
… 6 c 7 d 10 …
Converting an FA to an
equivalent NFA
• It is to be noted that according to the Kleene’s
theorem, if a language can be accepted by an FA,
then there exists a TG accepting that language.
Since, an NFA is a TG as well, therefore there
exists an NFA accepting the language accepted by
the given FA. In this case these FA and NFA are
said to be equivalent to each others.
Following are the examples of FAs to be
converted to the equivalent NFAs
Example

• Consider the following FA corresponding to (a+b)*b


a b b

- +
a
• The above FA may be equivalent to the following
NFA
a, b
Can the structure of above- NFAb be compared
+ with
the corresponding RE ?
Example

• Consider the following FA


b a,b
a
a
- 1 +
b
• The above FA may be equivalent to the following NFA
a, b a,b
a a
- 1 +
• Can the structure of above NFA be compared with the
corresponding RE ?
Task

Build an NFA equivalent to the following


FA a
2 4

a a
b a,b

1– a b 6+

b a b

3 b 5
Application of an NFA

• There is an important application of an NFA in


artificial intelligence, which is discussed in the
following example of a maze
- 1 2 3
4 L 5 O
6 M 7 P
8 N 9 +
Summing Up

• Examples of Kleene’s theorem part III


(method 3), NFA, examples, avoiding loop
using NFA, example, converting FA to
NFA, examples, applying an NFA on an
example of maze

You might also like