##### Document information

1

Recap Lecture 15

• 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

Docsity.com

2

Task

• Build an FA corresponding to the closure of the following FA

a

y1± y2

a

b b

Docsity.com

3

Task solution

Old States

New States after reading a b

Final z1±y1 y2z3 y1z2 z2+y1 y2z3 y1z2 z3y2 y1z2 y2 z3

a

y1± y2 a

b b

Docsity.com

4

Solution of the Task

a

z1 ± z3 a

b

z2+

b

b

a

Docsity.com

5

Task

Build an NFA equivalent to the following FA

2

a

1–

3

6+

4

5

a

a a,b

b

b

b

a b

b

a

Docsity.com

6

Solution of the Task

2

a

1–

3

6+

4

5

a

a

a,b

b

b

b

a,b

Docsity.com

7

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

**+**

Docsity.com

8

Example Continued ...

- and + indicate the initial and final states respectively. One can move only from a box labeled by other then L, M, N, O, P to such another box. To determine the number of ways in which one can start from the initial state and end in the final state, the following NFA using only single letter a, can help in this regard

Docsity.com

9

Example continued ... a a a

a

**-**

2 a

1 3

a

4 5

6 7 8 9 +

a a a

a a

a

a a

a a

a

a a

a Docsity.com

10

Example continued ...

• It can be observed that the shortest path which
leads from the initial state and ends in the final
state, consists of six steps *i.e. *the shortest string
accepted by this machine is aaaaaa. The next
larger accepted string aaaaaaaa.Thus if this NFA
is considered to be a TG then the corresponding
regular expression may be written as
aaaaaa(aa)*

Which shows that there are infinite many required ways

Docsity.com

11

Note

• It is to be noted that every FA can be considered to be an NFA as well , but the converse may not true.

• It may also be noted that every NFA can be considered to be a TG as well, but the converse may not true.

It may be observed that if the transition of null string is also allowed at any state of an NFA then what will be the behavior in the new structure. This structure is defined in the following

Docsity.com

12

NFA with Null String

** Definition:** If in an NFA, is allowed to be a
label of an edge then the NFA is called NFA
with (NFA-).
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.
There may be more than one transitions for certain
letter and there may not be any transition for a
certain letter. The transition of is also allowed
at any state.

Docsity.com

13

Example

Consider the following NFA with Null string The above NFA with Null string accepts the

language of strings, defined over Σ = {a, b},
**ending in b**.

- b

a, b

+ 1

Docsity.com

14

Example

Consider the following NFA with Null string The above NFA with Null string accepts the

language of strings, defined over Σ = {a, b},
**ending in a**.

a, b

, a a **-** + 1

Docsity.com

15

Task

• Determine the regular expression of the following NFA-

a

1**-**

4+

b 5

a a a

, b a

2

3**-
**

Docsity.com

16

Note

• It is to be noted that every FA may be considered to be an NFA- as well, but the converse may not true.

• Similarly every NFA- may be considered to be a TG as well, but the converse may not true.

Docsity.com

17

Two methods are discussed in this regard.
**Method 1**: Since an NFA can be considered to

be a TG as well, so a RE corresponding to the given NFA can be determined (using Kleene’s theorem). Again using the methods discussed in the proof of Kleene’s theorem, an FA can be built corresponding to that RE. Hence for a given NFA, an FA can be built equivalent to the NFA. Examples have, indirectly, been discussed earlier.

**NFA to FA
**

Docsity.com

18

**NFA to FA continued …
Method 2**: Since in an NFA, there more than one

transition for a certain letter and there may not be any transition for certain letter, so starting from the initial state corresponding to the initial state of given NFA, the transition diagram of the corresponding FA, can be built introducing an empty state for a letter having no transition at certain state and a state corresponding to the combination of states, for a letter having more than one transitions. Following are the examples

Docsity.com

19

Example

Consider the following NFA Using the method discussed earlier, the above

NFA may be equivalent to the following FA

a

1-

b

a b

2

3

4**+**

Docsity.com

20

Example Continued ...

a

b

a a

a, b

1- 2

4+

3 **
**

b

b

a, b

a

1-

b

a b

2

3

4+

Docsity.com

21

Example

• A simple NFA that accepts the language of
strings defined over ={a,b}, **consists of bb and
bbb
**

• The above NFA can be converted to the following FA

b

b

b 1- 4+ 2

3

b

Docsity.com

22

Example Continued ...

b

b b 1- 4+ 2 (3,4)+

a,b a a a

a, b

b

b

b 1- 4+ 2

3

b

Docsity.com

23

Task

• Build an FA corresponding to the following NFA
which accepts the language of strings **containing
bb**

b

b 3+ 1- 2

a, b a, b

Docsity.com

24

Solution of the Task

a

a

b

1-

a

b

a b

b (1,2) (1,2,3) +

(1,3)+**
**

It may be noted that the above method

seems to be complicated, hence an easier method discussed by Martin, follows as

b

b 3+ 1- 2

a, b a, b

Docsity.com

25

**NFA to FA continued …
**

** Method 3: **As discussed earlier that in an
NFA, there may be more than one transition
for a certain letter and there may not be any
transition for certain letter, so starting from the
initial state corresponding to the initial state of
given NFA, the transition table along with new
labels of states, of the corresponding FA, can
be built introducing an empty state for a letter
having no transition at certain state and a state
corresponding to the combination of states, for
a letter having more than one transitions.
Following are the examples

Docsity.com

26

Summing Up

• Applying an NFA on an example of maze, NFA with null string, examples, RE corresponding to NFA with null string (task), converting NFA to FA (method 1,2,3) examples

Docsity.com