Quiz 1: Solutions: 6.045J/18.400J: Automata, Computability and Complexity
Quiz 1: Solutions: 6.045J/18.400J: Automata, Computability and Complexity
Nancy Lynch
Quiz 1: Solutions
Nati Srebro, Susan Hohenberger
Please write your name in the upper corner of each page. (2 Points)
Q1-1
Problem 1:
True or False (18 points) Full credit will be given for correct answers. If you include justification for
your answers, you may obtain partial credit for incorrect answers.
True; all finite languages are regular languages and regular languages are closed under union.
2. True or False: If
is a regular language, then
must be a regular language. (Here,
denotes the reverse of string .)
False; we can show this language in not regular using techniques similar to Example 1.40 on
page 81 of Sipser. A common mistake is confusing the language above with
.
3. True or False: Regular expressions that do not contain the star operator can represent only finite lan-
guages.
True; the star operator in regular expressions is the equivalent of a loop in DFAs. If a deterministic
finite automata with states does not contain a loop, then at most it can recognize strings of length
less than . The set of such strings is finite.
4. True or False: Define "!#%$ , for a finite string , to be the string consisting of the symbols of
in even-numbered positions. For example, "!&' (')$+*,(- .
If
is a regular language, then ./!#%$0
must be regular.
Q1-2
5. True or False: For every pair of regular expressions and , the languages denoted by 6! $ and
! $ are the same.
True; intuitively, one can see that minimally both expressions are and that when the star operator
is exercised they both expand to expressions of alternating Rs and Ss, where both expressions
begin and end with . It is possible to prove that they describe equivalent sets using induction.
6. True or False: If
and
are languages such that
,
, and
are all regular, then
must
be regular.
False; consider
* and
*> .
Q1-3
Problem 2: (20 points) Consider the following NFA:
0
A B
ε 1
0,1 1
C D
1. (16 points) Convert this NFA into an equivalent DFA using the procedure we studied in class. Your
answer should be the state diagram of a DFA. Your diagram should include only the states that
are reachable from the start state. (Note: There are not more than a half-dozen states in the resulting
DFA). Please label your states in some meaningful way. You may explain your work, to receive more
credit for an incorrect answer.
0
AC BC
0 1
1
0 C DC
0 1
Q1-4
2. (3 points) What language is recognized by your DFA? Your answer may be either a regular expression
or an explicit description of the set.
3. (3 points) Give a DFA with two states that recognizes the same language.
1
0 A B
0 1
Q1-5
Problem 3: (20 points) Find a regular expression for the language recognized by this machine, using the
procedure we have studied in class: Show all your work, in particular, the state diagrams after the removal
0,1
A B
0,1
1
0 C
of each successive state. You may omit -transitions from your diagrams. Please start by giving the GNFA
before state removal and then remove states in the order ;D .
ε 0U1
S A B
0U1
1
C D
0 ε
ε 0U1
S A B
(0 U 1)0*1
D
(0 U 1)0*
Q1-6
After removing state :
ε
S A (0 U 1)0*1(0 U 1)
D
(0 U 1)0*
Q1-7
Problem 4: (20 points) Regular expressions are defined using three operators: union, concatenation,
and star. Suppose we define “Extended Regular Expressions” in the same way as regular expressions, with
the addition of the set intersection operator. For example, ! !5 .$ $ !&)! $ $ is an extended regular
expression, which denotes the set of words that both begin and end with .
Show that adding the intersection operator does not extend the power of ordinary regular expressions. Do
this by describing a procedure that, given an extended regular expression , produces an ordinary regular ex-
pression that represents the same language. You may use procedures described in class and in Sipser’s book
without saying how they work, e.g., you may say things like “convert the NFA to a DFA”. The description of
your procedure should be concise, but the procedure need not be the most efficient one possible.
Q1-8
Problem 5: (20 points) Prove that the following language
over the alphabet . is not regular:
"*'
and the number of =
in is equal to the number of = in
For example, the word is in
.
Claim:
is not regular.
Proof:
Assume to the contrary that
is regular. Let be the pumping length given by the pumping lemma.
Let be the string
. Because is a member of
and has length more than , the pumping
lemma guarantees that can be split into three pieces, * , satisfying the three conditions
of the lemma. We show that this is impossible.
Since, by the pumping lemma, we know that and , then for this , we see that
is made up of one or more ’s that all come before the ’c’ symbol. If we pump down, by letting * ,
<
then the resulting string is =?* , where the number of ’s before ’c’ is at least one less than
the number of ’s after it. This new string = is not in
. Thus, since can not be pumped,
is not
a regular language.
Q1-9