Professional Documents
Culture Documents
Deterministic Finite Automata Characterized as 5-tuple < S, A, T, s0, F > S is the set of states A is the alphabet T is the transition function: S xA S s0 is the start state F is the set of accepting states. Non-Deterministic Finite Automata Characterized as 5-tuple < S, A, T, s0, F > S is the set of states A is the alphabet T is the transition function: S x (A{}) PS s0 is the start state F is the set of accepting states.
Waseem Besada
1
a
b 2
2
3 4
{3} {2}
{4}
Waseem Besada
1
2 3 4
{3} {2}
{2}
{4}
=
=
Waseem Besada
a
{1,2,3,4}
b ?
{2} ?
?
{2,3,4} ?
TD({1,2,3,4},a) = ({1},a) ({2},a) ({3},a) ({2},a) = {3,4} {2} = {2,3,4} Similarly, TD({1,2,3,4},b) = {2}
Waseem Besada
a
{1,2,3,4}
b
{2}
{1,2,3,4}
{2,3,4}
{2,3,4}
{2}
{2,3,4}
{2}
Waseem Besada
Finally
4
b
a
{1,2,3,4}
b ?
{2} {2}
2 a 3 a
0 1 2 3 4
{0,3,4}
?
{2,3,4}
{2,3,4}
Waseem Besada
Exercise 2, solution
2. Construct directly (that is dont use the transformation procedure given in the lecture) a DFA for each of the following REs. a) a | b b) a | b* c) ab* | bc*
b
a
b
a,b
a,b
a,b
a c b b a,b a,b
a
b c
a,c
a,b,c
a,b
a)
c)
b)
7
Waseem Besada
Exercise 4, solution
4. Construct directly (that is dont use the transformation procedure given in the lecture) a NFA for each of the following REs. a) a*bc*| bc b) a* | ab a c
a
a b c a b
a)
b)
Waseem Besada
Exercise 5
5. Construct a DFA table for the following NFA transition table. The start state is 0 and there is one accepting state, 2.
a 0 1 {2} 2 b {1,2} {2} {1} {1}
b 0
1
a
2 b
Waseem Besada
Solution to exercise 5
DFA transition table
T 0 1 a b {0,1} {1,2} {1,2} ? ? NFA transition table
a 0 1 {2} 2 b {1,2} {2} {1} {1}
{1,2}
{1,2} {1,2}
a,b
a,b
Waseem Besada
10
Exercise 6
6. Consider the following NFA over the alphabet {a,b}: a) Find a regular expression for the language accepted by the NFA. b) Write down the transition table for the NFA. c) Transform the NFA into a DFA d) Draw a picture of the resulting DFA.
a 0
b
11
0
a
Waseem Besada
b
{2}
0
{1,2}
0
1 2
Waseem Besada
12
{2} {2}
Waseem Besada
13
{0,1,2}
a
{1,2}
Transition table for DFA T a b {0,1,2} {1,2} {1,2} {2} {2} {2} {2} {2}
b a,b
{2}
Waseem Besada
14
Exercise 7
7. Transform each of the following REs into a NFA, then into a DFA a) a*b* Solution to a) 2 1 b) a* | b* a b c) (a|b)*
a 1
b 6
Waseem Besada 15
a
{1,2,3} {1,2,3}
a 0 b 2 b 1 b
b
{2,3} {2,3} {2,3}
0 b a,b 0
a 1
b 2 3
Waseem Besada
16
What to do next?
Waseem Besada
17