\documentstyle[11pt,twoside]{article}
\input{defs-6045}
\begin{document}

\handout{ps4}{Homework Assignment 4}{February 21, 1992}
\due{Friday, Feb. 28}

\medskip

 Remember to write up problems 1 through
5 in such a way that each of these problems can be turned in
separately.  Put your name on EACH problem, with your last name
clearly written in CAPITAL LETTERS, and with the name of your 
RECITATION instructor.

\paragraph{Problems.}

\begin{enumerate}
\item[1.] (15 pts) Let $L$ be any regular language.  For each of the following, either
prove that the language generated is regular, or find a regular $L$ for which
the language generated is provably non-regular.
\begin{enumerate}
\item (8 pts) PREFIX($L$) = $\{w | w \mbox{ is a prefix of } x \in L\}$
\item (7 pts) MAX($L$) = $\{x \in L | \mbox{ for no other $y$ other than $\Lambda$ is } xy \in L\}$
\end{enumerate}

(Hint: For (a) you might consider constructing an NFA-$\Lambda$.)

\item[2.] (20 pts) Let $h$ be a homomorphism mapping $\Sigma^*$ to $T^*$.  Thus, 
	$h(x) = h(x_1) h(x_2) \ldots h(x_n)$
if $x = x_1 x_2 \ldots x_n$ and each $x_i$ is a symbol in $\Sigma$.
If $L$ is any language in $T^*$, we can define the ``inverse homomorphic
image'' of $L$ as

$$	h^{-1}(L) = \{ x : h(x) \in L \}.$$

That is, $h^{-1}(L)$ consists of all words in $\Sigma^*$ whose image, under
$h$, is in $L$.

Prove that if $L$ is regular language, then so is $h^{-1}(L)$.

(Hint: You could proceed as follows: assuming known a DFA accepting $L$, try to
construct one accepting $h^{-1}(L) $.)


\item[3.] (30 pts) Martin problem 8.9\ . ((a) and (b) are worth 5 pts each, (c) is worth 12 pts and
(d) is worth 8 pts.) 
Give precise proofs: in particular,
in (d) and (c) try to be precise
and understand the difference between periodic and eventually periodic.

(Hint: For (c), you might consider constructing a DFA whose state keep track 
of $N_a$ up to ... and of $N_b$ modulo...)

\item[4.] (25 pts) 
Suppose $M  = (Q,\Sigma,T,q_0,\delta,\gamma)$ is a state-output automaton
(Moore machine), as defined in Handout~9.  Then $M$ defines a mapping from
strings in $\Sigma^*$ to strings in $T^*$.  Let $M(x)$ denote the output produced
by $M$ when $M$ is given string $x$ as input.  

Let $L$ denote an arbitrary regular language over the alphabet $\Sigma$.
Prove that
	$M(L) \stackrel{\mbox{\tiny def}}{=}  \{ M(x) : x \in L \}$
is regular.

(Hint: Let $M'= (Q',\Sigma',q_0',\delta',A')$ be a DFA accepting $L$. 
Construct an NFA accepting $M(L)$ and whose
state space is $Q \times Q'$.)

\item[5.] (10 pts) Consider the hotel door locks described in part I of Handout~9.  Suppose
we have a particular such lock whose state space $Q = \{0,1,2,3,4\}$ and
whose encryption function $f$ is the identity function.  Suppose the
lock begins in state $0$.  Give a regular expression for the language
accepted by the lock.  The language accepted by the lock is the set of
strings, over the alphabet $\Sigma = \{0,1,2,3,4\}$, that cause the lock to
unlock.  For example, the string 
	0112234
is in the language while the string
	11213042
is not.


\end{enumerate}


\end{document}
