Академический Документы
Профессиональный Документы
Культура Документы
2
Deterministic Finite Automaton (DFA)
Input Tape
String
Output
“Accept”
Finite
or
Automaton
“Reject”
11 1
0
0,1
1
0111 111 1
0 0
0 0
q0 q12
q1 1
0
0,1
1
q0 q2
0 0
The alphabet of a finite automaton is the set
where the symbols come from: 1{0,1}
q3
The language of a finite automaton is the set
of strings that it accepts
Steven Rudich:
www.cs.cmu.edu/~rudich
rudich0123456789
q0 0,1
strings of 0s and 1s
L(M) = All
Steven Rudich:
www.cs.cmu.edu/~rudich
rudich0123456789
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
Fall 2006 Costas Busch - RPI 9
Alphabet {a , b }
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
10
head Initial Configuration
Input Tape
a b b a
Input String
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
Initial state
Fall 2006 Costas Busch - RPI 11
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
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
a b b a
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
accept
Fall 2006 Costas Busch - RPI 15
A Rejection Case
a b a
Input String
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
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
( )
Input Finished
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
reject
Fall 2006 Costas Busch - RPI 20
Language Accepted: L abba
a, b
q5
a, b
b a a b
q0 a q1 b q2 b q3 a q4
To reject a string:
all the input string is scanned
and the last state is non-accepting
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
Fall 2006 Costas Busch - RPI 23
Empty Tape
( )
Input Finished a, b
q5
b a a a, b
b
q0 a q1 b q2 b q3 a q4
accept
Fall 2006 Costas Busch - RPI 24
Another Example
a a, b
b a, b
q0 q1 q2
b a, b
q0 q1 q2
a a, b
b a, b
q0 q1 q2
a a, b
b a, b
q0 q1 q2
a a b
a a, b
accept
b a, b
q0 q1 q2
b a b
Input String
a a, b
b a, b
q0 q1 q2
a a, b
b a, b
q0 q1 q2
a a, b
b a, b
q0 q1 q2
b a b
a a, b
b a, b
q0 q1 q2
reject
33
Language Accepted: L {a b : n 0 }
n
a a, b
b a, b
q0 q1 q2
34
Another Example
Alphabet: {1}
1
q0 q1
1
Language Accepted:
0,1
1 0
1
0 0 00 1 001
0
Construct DFA to accept (0+1)*
1
Identify following DFA??
0
0 0
1 1
1
0 1
00(0+1)*
(0+1)*00(0+1)*
1 0
0 0
1
1
(0+1)*00
0
1
0 0
1
(0+1)*(00+01)
1 0
0 0
1 1
0
1
(a+b)*abb
Exercise
1. ab(a+b)*
2. a(a+b)*
3. (a+b)*a
4. (a+b)*aa (a+b)*
5. Exactly two strings baa and ab
6. (a+b)*(aa+bb) (a+b)*
7. (a+b) (a+b)b(a+b)*
8. all words containing aaa or bbb
9. (a*ba*ba*ba*)*
a, b
q0 a q1 b q2
b a accept
q3 a, b
Find language?
a, b
a, b
q1 q2