\documentclass[11pt]{article}

\usepackage{fullpage,times,epsfig}

\begin{document}

\section*{Computability and Logic Homework 4}

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

\bigskip\noindent
Problems 1 and 2 are worth 15 points each.  Problems 3 and 4 are worth 10 points each.

\paragraph{1.} Use the pumping lemma (carefully!) to prove that $\{a^nba^mba^{m+n}\ |\ m,n\geq 1\}$ is not regular.

\paragraph{2. Multiplication} Recall from Homework 2 the alphabet $\Sigma$ consisting 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\}
\]
In Homework 2 you showed that the set of sequences of column vectors in $\Sigma$ that represent correct binary additions is regular.  We can also use strings over this alphabet to represent binary \textbf{multiplications.}  An example of a correct multiplication is
\[
\begin{array}{ccccccc}
       & 0 & 0 & 1 & 0 & 1 & 0\\
\times & 0 & 0 & 0 & 1 & 0 & 1 \\
\hline
       & 1 & 1 & 0 & 0 & 1 & 0
\end{array} 
\qquad
\textrm{represented by}
\qquad
\left(\begin{array}{c} 0 \\ 0 \\ 1 \end{array}\right)
\left(\begin{array}{c} 0 \\ 0 \\ 1 \end{array}\right)
\left(\begin{array}{c} 1 \\ 0 \\ 0 \end{array}\right)
\left(\begin{array}{c} 0 \\ 1 \\ 0 \end{array}\right)
\left(\begin{array}{c} 1 \\ 0 \\ 1 \end{array}\right)
\left(\begin{array}{c} 0 \\ 1 \\ 0 \end{array}\right)
\]
Use the pumping lemma to show that the set of strings over $\Sigma^*$ representing correct binary multiplications is \textbf{not} regular.  (Hint: Consider the multiplication $(2^n+1)(2^n+1)$.


\paragraph{3. Derivations} Consider the following grammar over $\Sigma = \{a,b\}$:
\[\begin{array}{l}
S \to AA \\
A \to AAA \\
A \to a \\
A \to bA \\
A to Ab
\end{array}\]
\begin{itemize}
\item[a.] Give at least four distinct derivations of the string $babbab$.
\item[b.] For any $m,n,p > 0$, describe a derivation of $b^mab^nab^p$.
\end{itemize}

\paragraph{4. Constructing Grammars} Show that each of the following languages is context-free by giving a context-free grammar generating each:
\begin{itemize}
\item[a.] $\{w \in \{a,b,(,),+,{}^*,\emptyset\}^*\ |\ w
\textit{ is a regular expression over }\{a,b\}^*\}$  
\\ (The definition of regular expressions given in class ignored the use of parentheses.  For the purposes of this problem, if $R$ is a regular expression then so is $(R)$.)
\item[a.] $\{a^mb^nc^pd^q\ |\ m+n = p+q\}$
\item[b.] $\{a^mb^n\ |\ m \leq 2n \}$
\end{itemize}

\end{document}