Docstoc

L2

Document Sample
L2 Powered By Docstoc
					Non-deterministic FA (NFA)
• For each state, zero, one or more transitions are allowed on the same input symbol. • An input is accepted if there is a path leading to a final state.

An Example of NFA
In this NFA (Q,,,q0,F), Q = {q0,q1,q2},  = {0,1}, F = {q2} and  is:
Start 1

q1
1 0

0 OR
States q0 q1 q2

Inputs 0  {q1 } {q0 }
1

q0
1

q2

{q1,q2} {q2 } 

Note that each transition can lead to a set of states, which can be empty.

Language of an NFA
Given an NFA M, the language recognized by M is the set of all strings that, starting from the initial state, has at least one path reaching a final state after the whole string is read. Consider the previous example:
For input “101”, one path is q0q1q1q2 and the other one is q0q2q0q1. Since q2 is a final state, so “101” is accepted. For input “1010”, none of its paths can reach a final state, so it is rejected.

More Examples of NFA
a

Start

q0

q1

b

q2
0-9

b
0-9 q6 0-9

b
0-9

0-9

q1

0-9 .
q3

q4 0-9

E
q5

Start

q0

0-9

0-9

+,-

+,q2 0-9 q7 0-9

Class Discussion
Consider the language L that consists of all the strings over  = {0, 1} such that the third last symbol is a “1”. (a) Construct a DFA for L. (b) Construct an NFA for L.

Is NFA more powerful than DFA?

DFA and NFA
Is NFA more powerful than DFA? NO! NFA is equivalent to DFA.
Trivial
DFA Constructive Proof NFA

Constructing DFA from NFA
Given any NFA M=(Q,,,q0,F) recognizing a language L over , we can construct a DFA N=(Q’, ,’,q0’,F’) which also recognizes L:
• Q’ = set of all subsets of Q e.g., if Q = {q0, q1}, Q’ = {{}, {q0}, {q1}, {q0, q1}} • q0’ = {q0} • F’ = set of all states in Q’ containing a final state of M • ’({q1,q2, … qi}, a) = (q1,a)  (q2,a) ...  (qi,a)
a state in N a state in N

An Example of NFA  DFA
Consider a simple NFA:
0
0

1
q1

Start

q0

1 1

Construct a corresponding DFA:
Start
{q0}

1 1

{q1}

0
{q0, q1}

0
{}

1,0

1,0


				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:57
posted:11/12/2007
language:English
pages:8