0% found this document useful (0 votes)
162 views9 pages

Quiz 1: Solutions: 6.045J/18.400J: Automata, Computability and Complexity

This document contains solutions to a quiz on automata theory. It includes answers to 6 true/false questions about properties of regular languages and finite automata. It also contains solutions to 4 problems: (1) converting a non-deterministic finite automaton to a deterministic finite automaton, (2) finding a regular expression for a language recognized by a DFA, (3) showing that adding intersection to regular expressions does not increase their power, and (4) proving a language is not regular.

Uploaded by

AAtrox
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
162 views9 pages

Quiz 1: Solutions: 6.045J/18.400J: Automata, Computability and Complexity

This document contains solutions to a quiz on automata theory. It includes answers to 6 true/false questions about properties of regular languages and finite automata. It also contains solutions to 4 problems: (1) converting a non-deterministic finite automaton to a deterministic finite automaton, (2) finding a regular expression for a language recognized by a DFA, (3) showing that adding intersection to regular expressions does not increase their power, and (4) proving a language is not regular.

Uploaded by

AAtrox
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

6.045J/18.400J: Automata, Computability and Complexity Prof.

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.

In all parts of this question, the alphabet is   .


1. True or False: If
is a regular language and is a finite language (i.e., a language with a finite number
of words), then
 must be a regular language.

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.

True; given a DFA 12*3!546 879;:< ; $ that recognizes


, we can build an NFA
1>=?*@!546 879=58: < 8 $ that recognizes
A=?*B."!#%$C 0
 . Intuitively, the transition
function 7= is set so that from every state D there are outgoing transitions to any state that is
two hops (i.e., reachable in 1 by reading two input characters) away from D , where the new
transition symbol in 1 = is the second of the two symbols in 1 .

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.

“any string in  ending in a 1”: !5 $ 9  .

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 .

GNFA before state removal:

ε 0U1
S A B

0U1
1

C D
0 ε

After removing state  :

ε 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*

After removing state D :

[(0 U 1)0*1(0 U 1)]*(0 U 1)0*


S D

Regular expression representing the language recognized by the original DFA:


! .$& 9
 -!5 .$!5 $& 

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.

Input: Extended Regular Expression 


Procedure:
Given  , we work recursively to build regular expressions for all
its subexpressions, until we get  , a regular expression equivalent to  .
The interesting recursive step is the one where we use the intersection operator
(i.e., add this recursive step to the recursive definition of a regular expression
that we covered in class).

Then, the problem reduces to:


Given two ordinary regular expressions  and  , describe a
procedure for producing a regular expression for
!  $0
!  $ .

Now, doing this involves several steps:


Convert  and  to NFAs, then to DFAs, using the procedures given
in class. Then construct a DFA for the intersection
%! $0
!  '$ ,
using the product machine construction. Then convert the DFA to a GNFA
and then to a regular expression.

Output: Regular Expression  , which is equivalent to  .

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

You might also like