Lecture 3
Lecture 3
Lecture 3
1
Deterministic Finite Automaton (DFA)
Input Tape
String
Output
“Accept”
Finite
or
Automaton
“Reject”
2
Transition Graph
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
initial accepting
state state
transition
state
3
Recap Formal Definition
Deterministic Finite Automaton (DFA)
M = (Q, , , q0 , F )
Q : set of finite states
: set of finite input alphabet
: transition function δ : Q × Σ → Q
q0 : initial state
:Q → Q
* *
(q ,w ) = q
*
5
Alphabet = {a , b }
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
6
Recap Transition Table for
symbols
a b
q0 q1 q5
q1 q5 q2
states
q2 q5 q3
a, b
q3 q4 q5
q4 q5 q5
q5
q5 q5 q5 a, b
b a a b
q0 a q1 b q2 b q3 a q4
7
head Initial Configuration
Input Tape
a b b a
Input String
a, b
q5
b a, b
a a b
q0 a q1 b q2 b q3 a q4
Initial state
8
Scanning the Input
a b b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
9
Scanning forward…
a b b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
10
Scanning forward…
a b b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
11
Input finished
a b b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4 accept
a b a
Input String
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
13
Scanning forward…
a b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
14
Scanning forward…
a b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
15
Input finished
a b a
a, b
reject
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
Tape is empty
( )
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
reject
For DFA some authors denote empty string by 17
This automaton accepts only one string
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
18
To accept a string:
all the input string is scanned
and the last state is accepting
To reject a string:
all the input string is scanned
and the last state is non-accepting
19
Another Example
L = , ab , abba
a, b
q5
b a a a, b
b
q0 a q1 b q2 b q3 a q4
Accept Accept Accept
state state state
20
Language Accepted by DFA
21
For a DFA M = (Q, , , q0 , F )
Language accepted by M:
L(M ) = w : (q0 ,w ) F
* *
q0 w q q F
22
= {a , b }
q0 a q1 b q2
b a accept
q3 a, b
23
= {a , b }
q0 a q1 b q2
b a accept
q3 a, b
24
Consider the following DFA.
a a, b
b a, b
q0 q1 q2
a a, b
b a, b
q0 q1 q2
26
Another Example
Alphabet: = {1}
1
q0 q1
1
Language Accepted:
0,1
1 0
1
0 0 00 1 001
0
28
L (M ) = { all binary strings without
substring 001 }
1 0 0,1
1
0 1
0 00 001
0
29
Thank You!
31