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

\handout{quiz1}{Quiz 1}{March 5, 1992}


\medskip
Each of the 10 questions is worth 10 points and is of similar
difficulty.  Try to provide answers to all the questions even if you
do not solve them fully: we will give partial credit. Try also to
answer as precisely and concisely as you can.  You can consult your
class notes, your homeworks, the handouts given out in class and any
published book that you might have. 
%% (No other material is allowed.)
All answers must be written in the blue answer book.  Please write your
name, your section instructor's name, and your section time on the front
of the blue book.

\begin{center}
{\Large Good Luck !}
\end{center}


\begin{enumerate}
\item 
%% Giving DFA for a language described in English.
Give a DFA accepting the language 
$L = \{ x \in \{ 0, 1 \}^*:$  every block of three consecutive
symbols of  $x$  contains at least one $0 \}$.
For example, 10110010110 is in $L$, but 1011101001 is not.

\item 
%% Giving a regular expression for an NFA
Give a regular expression for the language accepted by the NFA 
in Figure~\ref{Fig-1}.
(Missing arrows are assumed to go to a dead state.)
You need not follow the general construction given in class---any way
of obtaining a correct expression is acceptable.

\begin{figure}[h]
\centerline{\mbox{\psfig{figure=/a/class/6.045/6045-spring-92/handouts/handout16/fig1.ps,height=2in}}}
\caption{NFA for Problem 2}
\label{Fig-1}
\end{figure}

%%Figure 1
%% states = ABC, start = A, accepting = A,C
%% edges on a: (A,A), (A,C)
%% edges on b: (A,C), (C,B), (B,A)

\item 
%% Proving an interesting language is regular.
Consider the 4-symbol alphabet $ \{ A, B, C, D \}$,
in which each symbol represents a two-bit binary word.
To be specific, consider the correspondence $A= {0\choose 0}$, 
$B= {0\choose 1}$, $C= {1\choose 0}$, $D= {1\choose 1}$.
If $x$ is a string over $\{ A, B, C, D \}$, then define
$p(x)$ to be the 
binary number formed by concatenating the upper bits of all the
symbols,
and $q(x)$ to be the number formed by concatenating the lower bits of $x$.
These are interpreted most-significant bit first. For example,
$p(DADB) = 1010$ (binary) $= 10$ (decimal), whereas 
$q(DADB) = 1011$ (binary) $= 11$ (decimal).

Let $L = \{ x \in \{ A, B, C, D \}^* : p(x) + 1 = q(x)\}$.

Thus, a string is in $L$ if the 
binary number formed by concatenating the lower bits of all the
symbols is exactly the sum of 1 and of the binary number formed from the upper
bits of all the symbols.
For example, ``DADB'' is in $L$, since $10+1=11$.

Prove that $L$ is regular.


\item 
%% NFA to DFA conversion
Following the procedure in lecture and the book,
give a DFA equivalent to the  NFA
 shown in Figure~\ref{Fig-2}.

%%Figure 2
%% states = ABCD, start = A, accepting = A
%% 0-edges: (D,C), (C,B), (B,A)
%% 1-edges: (A,B), (A,C), (A,D)

\begin{figure}[ht]
\centerline{\mbox{\psfig{figure=/a/class/6.045/6045-spring-92/handouts/handout16/fig2.ps,width=10cm}}}
\caption{NFA for Problem 4}
\label{Fig-2}
\end{figure}


\item 
%% Proving nonregularity
Prove that the following language is not regular.
$L = \{ a^i x : i \geq 10, x \in \{ b, c \}^* \mbox{ and } N_b(x) = N_c(x) \}$.

\item 
%% Output automata
Let $M$ be a state-output automaton (a Moore automaton):
\[
	M = (Q,\Sigma,T,q_0,\delta,\gamma)\ .
\]
Let $\gamma^*(x)$ denote the output of automaton $M$ when it is supplied
with input $x$.  

State a condition in terms of $Q,\Sigma,T,q_0,\delta$  and $\gamma$ 
characterizing exactly all the Moore automata such that the 
mapping $\gamma^*$ is one-to-one.  
(In other words, give a condition on $M$ such that for any $x$, 
knowing $\gamma^*(x)$ (and $M$), you can determine what $x$ is;
this condition should be the weakest possible such condition.)
Your ``condition on $M$'' can involve $\delta^*$ and $\gamma$, 
but should not involve any reference to $\gamma^*$.
You need not prove that your answer is correct.


%%%%%%%%%%%%%%%%%
%
%	NOTE TO RON:
%
%I adjoin \delta^* so that they can express the fact ``reachable'' in:
%	``For all reachable state q, for all y\in T, there is at most 
%	one s \in \Sigma st......''
%
%%%%%%%%%%%%%%%%%

\medskip In the following recall that $REV(x)$ denotes the reverse of $x$. For instance 
$REV(110) = 011$.

\item 
%% Context-free grammars
\begin{enumerate}
\item Give a CFG to generate the language
$L_1 = \{ x c y : x, y \in \{ a, b \}^*, |x| > |y| \}$.
\item  Give a CFG to generate the language
$L_2 = \{ x c y : x, y \in \{ a, b \}^*, y \neq REV(x) \}$.

\end{enumerate}

\item 
%% Showing a language is not CF
Show using the pumping lemma for CFL's that the following language is
not context-free:
$L = \{ x\ c\ REV(x)\ c\ x : x \in \{ 0, 1 \}^* \}$.

\item 
%% Decision procedures...
Describe in English an algorithm (procedure) for deciding each of the
following.  (Note: The procedures do not have to be efficient -- they
just have to be correct.)
\begin{enumerate}
\item for a given DFA, whether or not it accepts at least two distinct words.
\item for a given CFG, whether or not it generates at least two distinct
words.
\item for a given DFA and natural number n, whether there is an NFA
equivalent to the DFA that has fewer than n states.
\end{enumerate}

\item Prove or disprove the following:
``The intersection of an infinite number of regular languages is a regular language''.

\end{enumerate}
\end{document}


