# CMPSCI 601: Theory of Computation

### David Mix Barrington

### Fall, 2004

### Homework Assignment #1

#### Posted Wed 6 Oct 2004

#### Due Wed 20 Oct 2004, 2:00 p.m. by fax to 413-545-1249

#### Covers Lectures 1-5

These problems deal with four formal languages over the alphabet {0,1}.
Define the following function f from {0,1}^{*} to the integers:
f(λ) = 0 and for any string w, f(w0) = f(w) - 1 and f(w1) = f(w) + 1.
(Recall that λ is the empty string.)

A is defined to be the language {w: f(w) = 0}.

B is the language
{w: f(w) = 0 and for all v, if v is a prefix of w then f(v) ≥ 0}.

C is the language {w: w is in B and for all v, if v is a prefix of w then
f(v) ≤ 3}.

Finally, D is the language {w: w is in B and for all v, if
v is a prefix of w then f(v) ≤ 1}. (This said
"f(w) ≤ 1" before, which makes D the same language as B.)

(Recall that string u is a prefix of string v if there is a string x such
that ux = v.)

**Question 1:** Which of these four languages is regular? For each of
the regular ones, describe a DFA deciding it and a regular expression
denoting it. For each of the non-regular ones, prove that it is not regular.
(You may find the result of question 2 the easiest way to do this.)
**Question 2:** For each of the four languages, describe its
Myhill-Nerode equivalence classes. (Of course there are infinitely many of
these if the language is not regular.)
**Question 3:** For each of the non-regular languages, determine
whether or not it is context-free. If it is, give both a PDA and a grammar
for it. If it is not, prove that it is not.

Last modified 13 October 2004