Академический Документы
Профессиональный Документы
Культура Документы
-1-
Lecture 11
Objectives
Language of FSA
Non-determinism
o Nondeterministic Automaton
Formal definition
Meaning of NFA
Choosing where to go
Examples
Language of NFA
- transitions
DFA to NFA
The transition function of a DFA takes a state and an element of the
alphabet and returns a state, but the transition function of an NFA takes
a state and either an element of the alphabet or nothing, and returns an
element of the power set of the states of the NFA. As a on sequence of
the above, there is usually more than one way to read in a string with an
NFA. The rules for acceptance and rejection of strings are the same for
an NFA as they are for a DFA: if the final state is an accept state, the
string is accepted; otherwise, it is rejected. If the NFA is in a state that
does not define a transition for the next element of the string (and
defines no empty transition), the string is rejected.
While it would initially seem that an NFA is more capable than a
DFA, due to its extra 'features,' that turns out to not be the case. A DFA
can be constructed that is equivalent to any NFA. The procedure is as
follows:
1. The list of states in the DFA will consist of one state for every element
of the powerset of the NFA's states. For example, if an NFA has states
A, B, and C, the DFA will have states A, B, C, AB, AC, BC, ABC, and an
empty state.
Tahir Naseem/Handout 1
-2-
2. The alphabet for the DFA remains the same as it was for the NFA.
3. The initial state of the DFA is the one with the same name as the initial
state of the NFA.
4. The transition function is constructed in a manner that almost has to
be seen to be understood, but is basically as follows. Starting at the
initial state, find which combination of states each element of the
alphabet results in; the concatenation of these states is the state you
go to in the DFA. For example, if reading a 0 from state A allows you to
go to either state B or C in the NFA, then in the DFA reading a 0 from
state A will lead to state BC. Repeat the above procedure for each
resulting state until all possible transitions are covered. It will often
turn out that not all combinations of NFA states are actually reachable,
and as such can be completely omitted from the DFA.
5. The accept states of the DFA are all states that include at least one of
the accept states of the NFA. For example, if the NFA has states A, B,
and C, with A and C being the accept states, the accept states of the
DFA are A, C, AC, and ABC.
Once this process is complete, the DFA will be functionally identical
to the NFA.
Language of FSA: We can write a language from an FSA by analyzing it. To write a
language for given FSA we have to keep our eyes on acceptance words of that particular
FSA. It is elaborated with the help of examples below
Example 1:
a, b
-1
a, b
+2
a, b
Language for the given FSA is : Language having words of odd length
i.e. (a + b)((a + b)(a + b))*
-1
+3
b
4
+5
a, b
a, b
6
a, b
Tahir Naseem/Handout 1
-3-
Language for the given FSA is : Language having two words aa and bb
i.e. aa + bb
Choosing Where to Go
Tahir Naseem/Handout 1
-4-
Case 2
Tahir Naseem/Handout 1
-5-
Tahir Naseem/Handout 1
-6-
Example 1:
Construct an NFA over alphabet {0, 1} that accepts those strings that contain the pattern 001
somewhere.
0, 1
+q3
Language of NFA:
The NFA accepts string x * if there is some path that, starting from q0, leads to an
accepting state as the string is read left to right.
The language of an NFA is the set of all strings that the NFA accepts.
Transitions
Example 2:
Tahir Naseem/Handout 1
-7-
Example 3:
Construct an NFA that accepts all strings with an even number of 0s or an odd number
of 1s
q0