\documentclass[11pt]{article}
%%%
%%% You should not need to change anything between here and the after the next %%% block
%%%
\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in}
\setlength{\textwidth}{6.25in}
\setlength{\topmargin}{-0.4in}
\setlength{\textheight}{8.5in}
\setlength{\parindent}{0em}
\setlength{\parskip}{1.5ex}
\usepackage{mathpazo} % palatino math fonts
\usepackage{palatino}
\usepackage{amssymb, amsmath, amsfonts}
\usepackage{verbatim}
\usepackage{hyperref}
\usepackage{url}
\urlstyle{sf}
\newcommand{\nonterminal}[1]{{\sl #1}}
\newcommand{\terminal}[1] {{\textbf{#1}}}
\newcommand{\produces}{$\rightarrow$}
\newenvironment{bnfgrammar}{\begin{quote}\begin{tabbing} \hspace*{12em}\=\ \produces\quad\= \kill}{\end{tabbing}\end{quote}}
\newenvironment{smallbnfgrammar}{\begin{quote}\begin{tabbing} \hspace*{3em}\=\ \produces\quad\= \kill}{\end{tabbing}\end{quote}}
\newcommand{\bnfrule}[2]{\hfill\nonterminal{#1}\>\produces\>#2\\}
\renewcommand\theenumi{\alph{enumi}}
\newcounter{problemno}
\newcommand{\problem}[1]{\stepcounter{problemno}{\bf Problem \theproblemno: #1.}}
\newcommand{\handout}[3]{
\noindent\begin{center}\vspace{-10mm}{\bf University of Virginia - cs3102: Theory of Computation (Spring 2010)}\end{center}
{\Large \bf #1 \hfill Due: #3}}
\newcommand{\collaboration}[1]{
\begin{center}{\bf Collaborators and Resources:}\par{\framebox{\parbox[t]{5.5in}{#1}}}\end{center}
{\bf Collaboration Policy.} For this assignment, we will follow the same collaboration and resource policy as on Problem Set 1. See the Problem Set 1 handout for a full description of the policy.
{\bf Pledging.} It is not necessary to scribble a pledge on your submission: we assume all students are honest and honorable regardless of whether or not you scribble a pledge on your submission. If you are dishonorable, however, please write a note on your submission indicating this. If you want to write a pledge, please write something meaningful like, ``with honor'', not something rote and meaningless like ``pledge''.}
\newcommand{\handin}[2]{
{\Large \bf Name: \fbox{\Large #1 (#2)}}
\renewcommand{\thepage}{#2-\arabic{page}}}
\newenvironment{smallquote}{\begin{list}{}{%
\setlength\rightmargin{1.5em}\setlength\leftmargin{1.5em}\setlength\labelwidth{0pt}\setlength\itemindent{0pt}}\item[]}{\end{list}\vspace*{-1.3ex}}
\newcommand{\answer}[1]{\begin{smallquote}\emph{Answer:} #1\end{smallquote}}
\begin{document}
\handout{Problem Set 2}{PS2}{16 February 2010 (2:00pm)}
%%%
%%% ===========================================================
%%% Start editing here
%%%
\handin{Your Name}{mst3k} %%% replace with your name and email ID
\collaboration{
%%% List your collaborators and any resources you used here
I collaborated with Guadalahara's Special \#3 on problems 1-3.
I used my push-down hookahtomata to solve problem 8.
}
\problem{Constructing NFAs}
For each of the following languages, draw an NFA that recognizes the language using \emph{fewest possible number of states}. For all languages, assume $\Sigma = \left\{0, 1\right\}$.
\begin{enumerate}
\item $\left\{w | w \text{ starts and ends with different symbols. }\right\}$
\answer{Your answer here}
\item $\left\{w | w \text{ does not contain two consequtive $0$s. }\right\}$
\answer{Your answer here}
\item The language described by the regular expression $\left\{0,1\right\}^{*}01^{*}$.
\answer{Your answer here}
\end{enumerate}
\problem{Nondeterminstic Finite Automata} Answer these questions for the NFA $N_1$ in Sipser's Example 1.38. The extended transition function, $\delta^{*}$, is as defined in the \href{http://www.cs.virginia.edu/evans/cs3102-s10/classes/class5/rl-notes.pdf}{regular languages notes}.
\begin{enumerate}
\item What is the set of possible states of $N_1$ after processing input {\tt 1}?
\answer{Your answer here}
\item What is the set of possible states of $N_1$ after processing input {\tt 010}?
\answer{Your answer here}
\item Is there a string $w$ such that $\delta^{*}(q_1, w)$ does not include $q_1$? (If so, give the string $w$. If not, argue why no such $w$ exists.)
\answer{Your answer here}
\item Is there a string $w$ such that $\delta^{*}(q_1, w) = \left\{q_1, q_2, q_3, q_4\right\}$? (If so, give the string $w$. If not, argue why no such $w$ exists.)
\answer{Your answer here}
\end{enumerate}
\problem{Eliminating Epsilon} Prove that for every NFA $N$, there is an NFA $N'$ that recognizes the same language as $N$ but does not use any $\epsilon$-transitions. (A very short, very convincing proof is possible, but you will receive some credit for a longer proof.)
\answer{Your answer here}
\problem{Priming the Pump} Use the pumping lemma to prove the language, $PRIMES$, is non-regular:
\[
PRIMES = \left\{1^{n} | n \text{ is a prime number} \right\}
\]
\answer{Your answer here}
\problem{Regularity} For each language below, answer whether or not the language is regular. Include a convincing proof supporting your answer. You may use any proof technique you want, including construction, the pumping lemma, and the closure properties we have established for regular languages in the book, class, and other problems.
\begin{enumerate}
\item $\left\{a^{n}b^{m} | n \geq 0, 0 \geq m \leq 27 \right\}$
\answer{Your answer here}
\item $\left\{a^{n}b^{m} | m = 2n\right\}$
\answer{Your answer here}
\item $\left\{w | w \text{ is a valid email address}\right\}$ (for a summary of the specification of a valid email address, see \url{http://en.wikipedia.org/wiki/E-mail_address#RFC_specification})
\answer{Your answer here}
\item $\left\{w | w\text{ describes a chess position where White has a winning strategy}\right\}$
\begin{quote}
We describe a chess position with a sequence of 64 symbols from the alphabet
$\Sigma = \left\{ -, p, n, b, r, q, k, P, N, B, R, Q, K \right\}$
where the lower-case letters represent a white pieces and the upper-case letters represent the corresponding black pieces. White has a winning strategy for a given chess position if there is a way for white to win the game no matter what the other player does. (Note: you do not need to know anything more about chess to answer this.)
\end{quote}
\answer{Your answer here}
\item $\left\{w | \text{there is no string }x\text{ such that }w = xx\right\}$
\answer{Your answer here}
\item \emph{Bonus Challenge:}\\ $\left\{ w | w\text{ is a valid day in the Gregorian calendar in the form {\em month day, year}} \right\}$ \\
\begin{quote}
The Gregorian leap year rule is: every year that is divisible by four is a leap year, except for years that are exactly divisible by 100 but not divisible by 400. For example, ``February 7, 2010'', ``February 29, 2012'', and ``February 29, 2400'' are in the language, but ``February 29, 2010'' and ``February 29, 2100'' are not.
\end{quote}
\answer{Your answer here}
\end{enumerate}
\problem{Language Splitting} (Based on Sipser's 1.63a) Prove that any infinite regular language (that is, a regular language with an infinite number of strings) can be split into three infinite disjoint regular subsets.
\answer{Your answer here}
\problem{Language Operators} Define a new operation on languages, $\mathcal{D}$, as:
\begin{equation*}
\mathcal{D}(L) = \left\{w | w \in \Sigma^{*}\text{ and } ww^{R} \in L\right\}
\end{equation*}
(where $w^{R}$ denotes the reverse of $w$). Does $\mathcal{D}$ preserve regularity?
\answer{Your answer here}
\problem{Nondeterminstic Pushdown Automata} Draw a nondeterministic pushdown automaton that recognizes the language $\left\{w0w^{R} | w \in \left\{0, 1\right\}^{*}\right\}$. The fewer states you use, the better.
\answer{Your answer here}
\problem{Regular Grammars} A {\em regular grammar} is a replacement grammar in which all rules have the form $A \rightarrow aB$ or $A \rightarrow a$ where $A$ and $B$ represent any variable and $a$ represents a terminal. Prove that all regular languages can be recognized by a regular grammar.
\answer{Your answer here}
\problem{Context-Free Grammars} Consider the grammar $G$ below ($S$ is the start symbol, and $0$ and $1$ are terminals):
\begin{smallbnfgrammar}
\bnfrule{S}{$\epsilon$}
\bnfrule{S}{\nonterminal{S}\terminal{00}}
\bnfrule{S}{\terminal{11}\nonterminal{S}}
\bnfrule{S}{\terminal{0}\nonterminal{S}\terminal{1}}
\bnfrule{S}{\terminal{10}\nonterminal{S}}
\end{smallbnfgrammar}
\begin{enumerate}
\item Show that the string $111000$ can be produced by $G$ by showing a derivation that produces it.
\answer{Your answer here}
\item How many different derivations are there in $G$ to produce $111000$? (Support your answer with a clear argument.)
\answer{Your answer here}
\item What is the fewest number of rules that can be added to $G$ to produce a grammar that describes the language of all even-length strings in $\left\{0, 1\right\}^{*}$? (An excellent answer would include the rules to add, a proof why it is not possible it use fewer rules, and a proof that your modified grammar produces all even-length strings.)
\answer{Your answer here}
\end{enumerate}
\end{document}