Automata Theory Lec-02
Automata Theory Lec-02
Automata Theory Lec-02
Chapter 02
FINITE AUTOMATA
Deterministic Finite Automata
1. A Transition Diagram
2. A Transition Table
TRANSITION DIAGRAM
1 0 0,1
Start 0 1
q0 q1 q2
A=({q0,q1,q2},{0,1}, ,q0,{q2})
1 0 0,1
Start 0 1
q0 q1 q2
(q0,0)=q1
(q0,1)=q0 0 1
(q1,0)=q1 q0 q1 q0
(q1,1)=q2
(q2,0)=q2
q1 q1 q2
(q2,1)=q2 *q2 q2 q2
TRY THIS
Substring 011
Substring end with 01
How a DFA Process String
The language of the DFA is the set of all strings that the DFA
accepts. Suppose a1a2….an is a sequence of input symbols. We
start out with the DFA in its start state q0. We consult the
Transition Function
^
Extended Transition Function
Extended Transition Formula
^
takes a state p and a string w, and returns a
state q.
^
1. (q, €)=q
If are in state q and read no. of inputs then we
are still in q.
2. (q,w)= ((q,x),a)
^ ^
w xa
a last symbol
w string
x string consisting of all but the last symbol
Example with Transition Table
1 0 0,1
Start 0 1
q0 q1 q2
^
(q0, €)=q0
w= 11011 ^ ^
x= 1101 (q0,1)= ((q0, €),1) = (q0,1)=q0
^ ^
a= 1 (q0,11)= ((q0, 1),1)= (q0,1)=q0
^ ^
(q0,110)=((q0,11),0)= (q0,0)=q1
^ ^
(q0,1101)=((q0,110),1)=(q1,1)=q2
^ ^
(q0,11011)=((q0,1101),1)=(q2,1)=q2
The Language of a DFA
^
L(A)={w| (q0,w) is in F}
w = 110101
Nondeterministic Finite Automata
0,1
Start 0 1
q0 q1 q2
0 1
q0 q1 q2
Start
q0 q0 q0 q0 q0 q0
q1 q1 q1
(Stuck)
q2 q2
(Stuck) (Accepted)
1 0 1
0 0
Design an NFA
Start 0 1
q0 q1 q2
Basis:
^
(q0, €) = {q}
Induction:
Suppose w=xa
^
(q ,x)= {p1,p2,p3………pn}
k
^
Then (q ,w)= {r1,r2,r3………rm}
^ Processing of input 00101 by the NFA
0,1
Start 0 1
q0 q1 q2
^ (q0, €) = {q0}
^
(q0,0)= (q0,0)= {q0,q1}
^
(q0,00)= (q0,0) U (q1, 0)= {q0,q1} U Ø ={q0,q1}
^
(q0,001)=q0 U (q1,1)= q} U {q2} ={q0,q2}
^
(q0,0010)= (q0,0) U (q2,0) = {q0,q1} U Ø = {q0,q1}
^
(q0,00101)=(q1,1) U (q0,1)={q0} U {q2}={q0,q2}
Accepted
The language of NFA
n
In the worst case the smallest DFA can have 2 states
while the smallest NFA for the same language has n
states.
…..
0,1
Start 0 1
q0 q1 q2
0 1
Ø Ø Ø
{q0} {q0,q1} {q0}
{q1} Ø {q2}
*{q2} Ø Ø
{q0,q1} {q0,q1} {q0,q2}
{q0,q2} {q0,q1} {q0}
{q1,q2} Ø {q2}
{q0,q1,q2} {q0,q1} {q0,q2}
0,1
Start 0 1
q0 q1 q2
0 1
A Ø Ø Ø
B {q0} {q0,q1} {q0}
C {q1} Ø {q2}
*D *{q2} Ø Ø
E {q0,q1} {q0,q1} {q0,q2}
*F {q0,q2} {q0,q1} {q0}
*G {q1,q2} Ø {q2}
*H {q0,q1} {q0,q2}
{q0,q1,q2}
0,1
Start 0 1
q0 q1 q2
0 1 0 1
A Ø Ø Ø A A A
B {q0} {q0,q1} {q0} B E B
C {q1} Ø {q2} C A D
*D *{q2} Ø Ø *D A A
E {q0,q1} {q0,q1} {q0,q2} E E F
*F {q0,q1} {q0} *F E B
{q0,q2}
*G Ø *G A D
{q1,q2} {q2}
*H {q0,q1} *H E F
{q0,q1,q2} {q0,q2}
From the 8 states in fig starting in the start state
B, we can only reach states B,E and F. The other
five states are inaccessible from the start state.
1 0
Start 0 1
B E F
0
1
1 0
Start 0 1
{q0} {q0,q1} {q0,q2}
0
1
Theorem 2.11,2.12 (Self)
2.2.3,2.2.4,2.2.5,2.2.6,2.2.10,2.2.11(Self)
Thank You