CS5371 Theory of Computation: Lecture 4: Automata Theory II (DFA NFA, Regular Language)
CS5371 Theory of Computation: Lecture 4: Automata Theory II (DFA NFA, Regular Language)
Theory of Computation
Lecture 4: Automata Theory II
(DFA = NFA, Regular Language)
Objectives
•Give a formal definition of the non-
deterministic finite automaton (NFA)
and its computation
•Show that DFA = NFA in terms of
string decision power
•Properties of language recognized by
DFA (or NFA)
Formal Definition of NFA
•An NFA is a 5-tuple (Q, ,
, qstart, F),
where
–Q is a set consisting finite number of states
– is an alphabet consisting finite number of
characters
–
: Q x 2Q is the transition function
–qstart is the start state
–F is the set of accepting states
start 1 0, 1
q1 q2 q3 q4
(q1, 0) = {q1},
(q1, 1) = {q1,q2},
(q1,
) = { }, …
Formal Definition of NFA’
s
Computation
•Let M = (Q, ,
, qstart, F) be an NFA
•Let w be a string over the alphabet
•Then, M accepts w if we can write
w = w1 w2 …wn such that each wi 2 and a
sequence of states r0, r1, …, rn in Q exists
with the three conditions:
–r0 = qstart
–ri+1 2 (ri, wi+1) compare this with DFA
–rn 2 F
DFA = NFA
(in terms of string decision power)
Theorem: (1) If a language L can be
recognized by a DFA, then there exists an
NFA that can recognize L; (2) If a
language L’can be recognized by an NFA,
then there exists a DFA that recognizes L’.
start 1 0, 1
q1 q2 q3 q4
R(w’
) = {q1, q3}, R(w’
0) = ?? R(w’
1) = ??
DFA = NFA (Proof Idea)
•By looking at R(w’
), how can we determine if
the NFA accepts w’ ?
–Question: If q is an accepting state, and we
know that q 2 R(w’ ), will the NFA accepts w’?
–Answer: Yes, since q 2 R(w’
) means that by
reading w’, there is some way we can reach the
accepting state q in NFA. By definition, w’is
accepted
•In fact, w’is accepted if and only if some
accepting state q is in R(w’
)
DFA = NFA (Proof Idea)
•If we can list out the R(w)’s for all w, we
can simulate the computation of NFA
•However, there are infinite number of
strings w1, w2, … (what could we do?)
•How about the number of possible set of
states, R(w1), R(w2), …, that are just
reachable by an NFA?
–Are there infinite of them?
DFA = NFA (Formal Proof)
•Let N = (Q, , , qstart, F) be the NFA
recognizing some language A
•We construct a DFA D = (Q’ ’
, , , qstart ’
, F’
)
recognizing A as follows
•Q’= 2Q
each state of D corresponds to a particular R(w)
•qstart ’
= the state corresponding to R()
= E(qstart)
where E(X) = {X} [ the set of states that NFA
N can reach from X by following only arrows
DFA = NFA (Formal Proof)
•F’
= { Y 2 Q’
| Y contains an accept state of N }
D accepts if one of the possible states that N can
now be in is an accept state
and a 2 ,
•For Y 2 Q’
’
(Y, a) = { q | q 2 E(
(y,a)) for some y 2 Y }
start 1
a
b
a 2 3
a,b
Constructing DFA from NFA (Example)
b
a,b
a b b
{} {1} {2} {3}
a b a
b a
a,b 3{1,3}
{1,2} {2,3} a {1,2,3}
a,b
a 1
start
b b
a
start a
2 3
a,b
Properties of Language
Recognized by DFA or NFA
Theorem: If A and B are languages
recognized by DFAs, then the language
A [ B = { x | x 2 A or x 2 B }
can also be recognized by a DFA.
N2
Properties of Language
Recognized by DFA or NFA
Theorem: If A and B are languages
recognized by DFAs, then the language
A o B = { xy | x 2 A and y 2 B }
can also be recognized by a DFA.
N
Properties of Language
Recognized by DFA or NFA
Theorem: If A is a language that can be
recognized by a DFA, then the language
A* = { x1x2…xk | k ¸ 0 and xi 2 A } can
also be recognized by a DFA.
N
Regular Language
•The Union, Concatenation, and Star
operations are called regular operations
•Languages that can be recognized by
DFA are called regular language
Practice at Home
•We have given informal construction of N,
showing that the class of regular languages is
closed under union operations
That is, if we take two regular languages and perform
union operations on them, the resulting language is
also a regular language