\documentclass[11pt]{article}

\usepackage{fullpage,times,epsfig}

\begin{document}

\section*{Computability and Logic Homework 1}

\noindent
\textbf{Due: } Thursday, September 15, 2005

\subsection*{Practice Problems (Don't hand in)}

Exercises 11.2.1--9 from the textbook.

\subsection*{Problems to Hand In}

\noindent
Each of problems 1 through 5 is worth 10 points.

\paragraph{1. Disjunctive Normal Form}

A regular expression is in \emph{disjunctive normal form} if it is of
the form $R_1 + \cdots + R_n$, where no $R_i$ contains any occurrences
of ``$+$''.  In this problem you will prove that every regular
expression is equivalent to one in disjunctive normal form.
\begin{itemize}
\item[a.] Give a recursive definition for a function $\mathit{DNF}$
  from regular expressions to regular expressions such that
  $\mathit{DNF}(R)$ is equivalent to $R$ and in disjunctive normal
  form.
\item[b.] Prove, by induction on $R$, that your function
  $\mathit{DNF}$ meets the specification in part (a).
\end{itemize}

\paragraph{2.} Construct \textbf{deterministic} finite automata to
accept each of the following languages.  (You do not have to prove
your constructions correct formally.)
\begin{itemize}
\item[a.] $\{w \in \{a,b\}^*\ |\ \textit{each }a \textit{ in } w
\textit{ is immediately preceded by a } b \}$
\item[b.] $\{w \in \{a,b\}^*\ |\ w \textit{ has an odd number of }
a\textit{'s and an even number of }b\textit{'s}\}$
\item[c.] $\{w \in \{a,b\}^*\ |\ w \textit{ has both }ab
\textit{ and }ba\textit{ as substrings}\}$
\end{itemize}

\paragraph{3.} Construct \textbf{nondeterministic} finite automata to
accept the languages represented by each of the following regular
expressions:
\begin{itemize}
\item[a.] $(ab)^*(ba)^* + aa^*$
\item[b.] $(ba +b)^* + (bb+a)^*$
\end{itemize}

\paragraph{4. Addition}

Let our alphabet $\Sigma$ be the set of all 3-place binary vectors:
\[
\Sigma = \left\{ \left(\begin{array}{c}0\\ 0\\ 0\end{array}\right),
\left(\begin{array}{c}0 \\ 0\\ 1\end{array}\right),
\left(\begin{array}{c}0 \\ 1\\ 0\end{array}\right), 
\ldots,
\left(\begin{array}{c}1 \\ 1 \\ 1 \end{array}\right)
\right\}
\]

An addition of binary numbers can be represented by a string in $\Sigma^*$.  For instance, the (correct) binary addition:
\[
\begin{array}{ccccc}
  & 0 & 1 & 0 & 1 \\
+ & 0 & 1 & 1 & 0 \\
\hline
  & 1 & 0 & 1 & 1
\end{array} 
\qquad
\textrm{is represented by:}
\qquad
\left(\begin{array}{c} 0 \\ 0 \\ 1 \end{array}\right)
\left(\begin{array}{c} 1 \\ 1 \\ 0 \end{array}\right)
\left(\begin{array}{c} 0 \\ 1 \\ 1 \end{array}\right)
\left(\begin{array}{c} 1 \\ 0 \\ 1 \end{array}\right)
\]
which is a string of length 4.

\medskip Let $L \subseteq \Sigma^*$ be the set of strings that
represent correct additions.  Show that $L$ is regular by exhibiting a
DFA that accepts it.  (Note that a DFA must scan its input from left
to right, even though carries in an addition propagate from right to
left!)  Argue informally that your DFA is correct, briefly describing
what each state represents.  You should not need very many states; try
to design a DFA with as few states as you can.

\paragraph{5. Searching}
\begin{itemize}
\item[a.] Show that for any regular language $R$, the language of
  strings that contain an element of $R$ as a substring is regular.
  You should not need to construct any automata for this part.
\item[b.] Draw a DFA to accept the language consisting of strings over
  $\Sigma = \{a,b\}$ that contain either $abba$ or $baab$ as a
  substring.
\item[c.] Draw an NFA that accepts the same language as in part (b)
  but is simpler than your DFA.
\end{itemize}


\end{document}