Documente Academic
Documente Profesional
Documente Cultură
Homework 2 Problems
October 8, 2015 Timothy Johnson
(b) Give all the strings of length three or less accepted by the automaton.
, a, b, c, ba, bb, bc, ca, cb, cc, aaa, aab, aac, aba, abb, baa, bab, bac, bca, bcb, bcc,
caa, cab, cac, cba, cbb, cbc, cca, ccb, ccc
(c) Convert the automaton to a DFA. (Please construct the table, and then draw the dia-
gram.)
1
2. Exercise 3.1.1 on page 91 of Hopcroft et al.
Write regular expressions for the following languages.
(a) The set of strings over alphabet {a, b, c} containing at least one a and at least one b.
(A + B + C) (A(A + B + C) B + B(A + B + C) A)(A + B + C)
(b) The set of strings of 0s and 1s whose tenth symbol from the right end is 1.
(0 + 1) 1(0 + 1)9
(c) The set of strings of 0s and 1s with at most one pair of consecutive 1s.
(0 + 10) (11 + )(0 + 10)
2
(0)
R11 = 1 +
(0)
R12 = 0
(0)
R13 = ;
(0)
R21 = 1
(0)
R22 =
(0)
R23 = 0
(0)
R31 = ;
(0)
R32 = 1
(0)
R33 = 0 +
(1)
(b) Give all the regular expressions Rij . Try to simplify the expressions as much as possible.
3
(1) (0) (0) (0) (0)
R11 = R11 + R11 (R11 ) R11
= (1 + ) + (1 + )(1 + ) (1 + )
= 1
(1) (0) (0) (0) (0)
R12 = R12 + R11 (R11 ) R12
= 0 + (1 + )(1 + ) 0
= 1 0
(1) (0) (0) (0) (0)
R13 = R13 + R11 (R11 ) R13
=;
(1) (0) (0) (0) (0)
R21 = R21 + R21 (R11 ) R11
= 1 + 1(1 + ) (1 + )
= 1+
(1) (0) (0) (0) (0)
R22 = R22 + R21 (R11 ) R12
= + 1(1 )0
= + 1+ 0
(1) (0) (0) (0) (0)
R23 = R23 + R21 (R11 ) R13
=0
(1) (0) (0) (0) (0)
R31 = R31 + R31 (R11 ) R11
=;
(1) (0) (0) (0) (0)
R32 = R32 + R31 (R11 ) R12
=1
(1) (0) (0) (0) (0)
R33 = R33 + R31 (R11 ) R13
=0+
(2)
(c) Give all the regular expressions Rij . Try to simplify as much as possible.
4
(2) (1) (1) (1) (1)
R11 = R11 + R12 (R22 ) R21
= 1 + 1 0( + 1+ 0) 1+
= (1 + 01)
(2) (1) (1) (1) (1)
R12 = R12 + R12 (R22 ) R22
(1) (1)
= R12 (R22 )
= 1 0( + 1+ 0)
= (1 + 01) 0
(2) (1) (1) (1) (1)
R13 = R13 + R12 (R22 ) R23
= ; + 1 0( + 1+ 0) 0
= (1 + 01) 00
(2) (1) (1) (1) (1)
R21 = R21 + R22 (R22 ) R21
(1) (1)
= (R22 ) R21
= ( + 1+ 0)1+
= 1+ ( + 01+ )
(2) (1) (1) (1) (1)
R22 = R22 + R22 (R22 ) R22
(1)
= (R22 )+
= ( + 1+ 0)+
= (1+ 0)
(2) (1) (1) (1) (1)
R23 = R23 + R22 (R22 ) R23
(2) (1)
= (R22 ) R23
= ( + 1+ 0) 0
= (1+ 0) 0
(2) (1) (1) (1) (1)
R31 = R31 + R32 (R22 ) R21
= ; + 1( + 1+ 0) 1+
= 1(1+ 0) 1+
(2) (1) (1) (1) (1)
R32 = R32 + R32 (R22 ) R22
= 1 + 1( + 1+ 0)+
= 1(1+ 0)
(2) (1) (1) (1) (1)
R33 = R33 + R32 (R22 ) R23
= (0 + ) + 1( + 1+ 0) 0
= 0 + 1(1+ 0) 0 +
5
(3)
The language of our DFA is R13 .
(e) Construct the transition diagram for the DFA and give a regular expression for its lan-
guage by eliminating state q2 .
This gives us the following regular expression for the language of our DFA:
6
Convert the following regular expressions to NFAs with -transitions. (Ive simplified my
solutions somewhat, but some students may turn in equivalent solutions that are more com-
plicated because they followed the book exactly, which is fine.)
(a) 01 .
(b) (0 + 1)01.
(c) 00(0 + 1) .