Unit 01 - Part 3
Unit 01 - Part 3
Finite Automata
Finite Automata
Finite automata are recognizers; they simply say "yes" or "no" about each possible input string.
Finite automata come in two flavors:
(a)Nondeterministic finite automata (NFA) have no restrictions on the labels of their edges. A symbol
can label several edges out of the same state, and ε, the empty string, is a possible label.
(b) Deterministic finite automata (DFA) have, for each state, and for each symbol of its input alphabet
exactly one edge with that symbol leaving that state.
A FA can be represented by a 5-tuple (Q, ∑, δ, q0, F)
Nondeterministic Finite Automata
A nondeterministic finite automaton (NFA) consists
of:
1. A finite set of states Q.
2.A set of input symbols ∑ , the input alphabet. We assume that E, which stands for the
empty string, is never a member of ∑ .
3.A transition function δ that gives, for each state, and for each symbol in a set of
next states.
4. A state q0 from Q that is distinguished as the start state (or initial state).
5.A set of states F, a subset of Q that is distinguished as the accepting states (or final
states).
This NFA graph is very much like a transition diagram, except:
a) The same symbol can label edges from one state to several different states, and
b) An edge may be labeled by c, the empty string, instead of, or in addition to, symbols from the input
alphabet.
b) CONCATENATION
Suppose r = st. The start state of N (s) becomes the start state of N (r), and the accepting state of N(t)
is the only accepting state of N(r). Thus, N(r) accepts exactly L(s)L(t), and is a correct NFA for r = st.
c) CLOSURE
Suppose r = s*. Here, i and f are new states, the start state and lone accepting state of N (r) .
N(r) accepts ε, which takes care of the one string in L(s)0, & accepts all strings in L(s)1,
L(s)2 and so on
Finally, suppose r = (s). Then L(r) = L(s), and we can use the NFA N(s) as N(r).
The properties of N(r) are as follows:
1. N(r) has at most twice as many states as there are operators and operands
in r.
2. N(r) has one start state and one accepting state.
3.Each state of N (r) other than the accepting state has either one outgoing transition on a
symbol in C or two outgoing transitions, both on ε.
Problem
Construct an NFA for r = (a | b) * a b
The following figure shows parse tree for r
i) NFA for a ii) NFA for a
Divide Q (set of states) into two sets such that one set contains all the non-final states and other set
contains all the final states.
This partition is called P0.
Step 4:
Increment k by 1.
Find Pk by partitioning the different sets of Pk-1 .
In each set of Pk-1 , consider all the possible pair of states within each set and if the two states are
distinguishable, partition the set into different sets in Pk.
Two states q1 and q2 are distinguishable in partition Pk for any input symbol ‘a’,
Step 5
Repeat step-04 until no change in partition occurs.
In other words, when you find Pk = Pk-1, stop.
Step 6:
All those states which belong to the same set are equivalent.
The equivalent states are merged to form a single state in the minimal DFA.
Number of states in Minimal DFA = Number of sets in Pk
Example:
Construct NFA for the RE (a|b)*abb and also convert it into Minimized DFA
Step 1: NFA Construction using Thompson Method
(a|b)*abb
=C
Dtran[D, a] = ε – closure (move(D, a))
= ε – closure (3, 8)
= {1, 2, 3, 4, 6, 7, 8 }
=B
Dtran[D, b] = ε – closure (move(D, b))
= ε – closure (5, 10)
= {1, 2, 4, 6, 7, 10 }
=E
Dtran[E, a] = ε – closure (move(E, a))
= ε – closure (3, 8)
= {1, 2, 3, 4, 6, 7, 8 }
=B
Dtran[E, b] = ε – closure (move(E, b))
= ε – closure (5)
= {1, 2, 4, 5, 6, 7 }
=C
Step 3: DFA Transition Table