Professional Documents
Culture Documents
Finite Automata: A Simple Model of Computation
Finite Automata: A Simple Model of Computation
A simple model of
computation
Outline
• Deterministic finite automata (DFA)
– How a DFA works
– How to construct a DFA
• Non-deterministic finite automata (NFA)
– How an NFA works
– How to construct an NFA
• Equivalence of DFA and NFA
• Closure properties of the class of languages
accepted by FA
INPUT TAPE
Store input of the DFA
Can be of any length
q a (q,a) 0 1 0
s 0 s s f
s 1 f 1
f 0 f Transition diagram
f 1 s
Transition function
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 7
How to define a DFA
• a 5-tuple (Q, , , s, F), where That’s why it’s called
– a set of states Q is a finite set a finite automaton.
– an alphabet is a finite, non-empty set
– a start state s in Q
– a set of final states F contained in Q
– a transition function is a function Q Q
s f
1
Input: 001101
ACCEPT
0 0 1 1 0 1
configurations of M 0 1 0
(s, ), (s, 00),
(s, 01101), (f, ), s f
1
(f, 0011011001),
(f, 1111), (f, 011110) Transition diagram of M
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 10
Yielding next configuration
Definition
• Let M = (Q, , , s, F ) be a deterministic finite automaton,
and (q0, 0) and (q1, 1) be two configurations of M.
• We say (q0, 0) yields (q1, 1) in one step, denoted by (q0, 0)
M (q1, 1), if (q0, a) = q1, and 0=a 1, for some a .
• When a configuration yields another configuration, the first
symbol of the string is read and discarded from the
configuration.
• Once a symbol in an input string is read, it does not effect
how the DFA works in the future.
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 11
Example: yielding next configuration
0 1 0 (s, 001101)
M (s, 01101)
s f
M (s, 1101)
M (f, 101)
1
M (s, 01)
M (s, 1)
001101 M (f, )
s f
1
(s, 001101) (s, 01001)
*M (f, 101) *M (f, 001)
*M (s, 01) *M (f, 001)
0 1 0
s f
1
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 16
Example
0 0 0, 1
0
1 1
0
s 0 1
1 1 0, 1
1
1 0 0
s 0 1
1 1 0, 1
Got 1
nothing
1 0 0
Got 1 as
substring Got 11 as Got 11 Got 11 and 00
substring and got 0 as substrings
3n+2 2 1 6n+5 2
3n+2 2 1 6n+5 2
q0 1 q1
q0
1
q1 0 q2 1
1
q1 1 q0 0
q1 q2
q2 0 q1 0
q2 1 q2
DFA
0 1
0 0 1 0 1
1 1
1 0
0
0 1
0,1
1 1
Same as the
definition for
a DFA
0,1
0 0
0,1
• {w {0,1}* | w has 00 and
0,1
11 as substrings and 00
1 1
comes before 11}
0,1 0,1
1 1
s q f
0,1
0 1
1 1
s s,q s,q,f
0 0
L(M)={ai bj ck | i, j, k 0}
q3 q4
q4 q3
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 43
Constructing the equivalent DFA
Let Mn = (Q, , , s, F) be any NFA. We construct a
DFA Md =(2Q, , ', E(s), F'), where :
– '(q',a) = {rE(p)| p (q,a) } and
qq'
– F' = {f Q | f F })
ε DFA
a p r
q ε
a
ε
q0, q1, q1, q2, q2 q3 q3,q4
q1 q2
q2, q3 q3
a b
q3 a q4
E(q) R
rR
q r
a
E(q) P R k+1 steps
r rR
q
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 56
Proof
From the induction hypothesis and (E(q), ) *Md (P, ε) in k
steps, we know that there exists pP such that (q, )*Mn(p,ε)
(i.e. (q, a) *Mn (p, a) ).
Since (P, a) Md (R, ε), there exists rR such that r= (p, a).
Then, for some rR, (p, a) *Mn (r, ε).
Thus, (q, ) *Mn (p, a) *Mn (r, ε) for some rR.
a
E(q) P R k+1 steps
pP
p
a
q r rR
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 57
Closure Properties
• The class of languages accepted by FA’s is
closed under the operations
– Union
– Concatenation
– Complementation
– Kleene’s star
– Intersection
ε
ε
sA sB
ε MB
MA
sA
MA
DFA only
s sA fA f
0 p0,q0
1 1
q0 1
1 p1,q1
1 p0,q1 0
1
1
0
0 1 p0,q2
q1 q2 p2,q0
0 1
1
p1,q0
1 p1,q2
0,1 1 1
p0 p1 p2 1
p2,q1
p2,q2
Jaruloj Chongstitvatana 2301379 Chapter 2 Finite Automata 67
Check list
Basic Advanced
Explain how DFA/NFA work Prove DFA/NFA accepting a
(configuration, yield next language
configuration) Prove properties of DFA/NFA
Find the language accepted by Configuration change
DFA/NFA
Under some modification
Construct DFA/NFA accepting a etc.
given language
Prove some properties of
Find closure of a state languages accepted by
Convert an NFA into a DFA DFA/NFA
Prove a language accepted by FA Under some modification
Construct FA from other FA’s Surprise!