\documentclass[11pt]{article}
\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{amssymb, amsmath, amsfonts}
\usepackage{mathpazo} % palatino math fonts
%\usepackage{palatino}
%\usepackage{utopia}
\usepackage{latexsym}
\usepackage{verbatim}
\usepackage{graphics}
\usepackage[hyperindex]{hyperref}
\usepackage{url}
\urlstyle{sf}
\newcommand{\marginquote}[2]{\marginpar[\footnotesize \raggedleft {\em #1} \\
\scriptsize #2]
{\footnotesize \raggedright {\em #1} \\ \scriptsize #2}}
\newcommand{\sidequote}{\marginquote}
\newcommand{\shortsection}[1]{\textbf{#1. }}
\newenvironment{enumtight}{\vspace*{-2ex}\begin{enumerate}\setlength{\itemsep}{0cm} \setlength{\parskip}{0cm}\setlength{\parskip}{0cm}\setlength{\parsep}{3pt}\setlength{\topsep}{3pt}\setlength{\partopsep}{0pt}}{\end{enumerate}\vspace*{-1.3ex}}
\newenvironment{itemtight}{\vspace*{-2ex}\begin{itemize}\setlength{\itemsep}{0cm} \setlength{\parskip}{0cm}\setlength{\parsep}{3pt} \setlength{\topsep}{3pt}\setlength{\partopsep}{0pt}}{\end{itemize}\vspace*{-1.3ex}}
\newenvironment{smallquote}{\vspace*{-2ex}\begin{list}{}{%
\setlength\rightmargin{1.5em}\setlength\leftmargin{1.5em}\setlength\labelwidth{0pt}\setlength\itemindent{0pt}}\item[]}{\end{list}\vspace*{-1.3ex}}
\newcommand{\nonterminal}[1]{{\sl #1}}
\newcommand{\terminal}[1] {{\textbf{#1}}}
\newcommand{\produces}{$\rightarrow$}
\newenvironment{bnfgrammar}{\begin{quote}\begin{tabbing} \hspace*{3em}\=\ \produces\quad\= \kill}{\end{tabbing}\end{quote}}
\newenvironment{bnfgrammarm}[1]{\begin{quote}\begin{tabbing} #1\qquad\=\ \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\\}
\newcounter{problemno}
\newcommand{\problem}[1]{
\stepcounter{problemno}
{\bf Problem \theproblemno: #1.}}
\newcommand{\handout}[3]{
\renewcommand{\thepage}{#1-\arabic{page}}
\noindent
\begin{center}
\framebox{
\vbox{
\hbox to 5.78in { {\bf University of Virginia - cs3102: Theory of Computation} \hfill Spring 2010 }
\vspace{4mm}
\hbox to 5.78in { {\Large \hfill #2 \hfill} }
\vspace{-5mm}
\hbox to 5.78in { { \hfill {\bf #3}} }
}
}
\end{center}
\vspace*{4mm}
}
\newcommand{\fillin}[1]{\vspace*{#1}}
% % \begin{center}
% \ \\ \framebox{
% \vbox{
% \hbox to 6.0in {\vspace{#1}}}
% }
% %\end{center}
%}
\newcommand{\fillinshort}[1]{
\framebox{
\vbox{
\hbox to #1 {\vspace{4mm}}}}
}
\newcommand{\fillinline}[1]{
\framebox{
\vbox{
\hbox to #1 {\vspace{8mm}}}}
}
\renewcommand\theenumi{\alph{enumi}}
\newcommand{\answer}[1]{\par \bigskip \begin{smallquote}\emph{Answer:} #1\end{smallquote}}
\begin{document}
\handout{X2}{Exam 2}{13 April (2:01pm)}
{\bf Honor Policy.} For this exam, you must {\bf work alone}. You may not aid or accept aid from other students.
You may consult the single page of notes you prepared before this exam as much as you want. For no more than 30 minutes, you may also consult any other non-human resources you want including the course textbook, handouts, your notes, other books, and on-line materials. If you use any resources other than the course materials, cite the resources you used in your answer. You may start your additional resource clock at any point you want after starting the exam. From that time, you may use any of these resources you want, but must stop using them and not consult them further after 30 minutes has expired. Other than the resource use time limit, there is no time limit for this exam. However, we expect a well-prepared student should be able to complete the exam in about two hours.
{\bf Directions.} Answer all 5 questions, including all sub-parts. If you wish to type your answers, use the LaTex template here: \url{http://www.cs.virginia.edu/cs3102/exams/exam2-template.tex}.
You may use the backs of pages for your scratch work, but we will only grade answers that are written in the answer spaces, or that are found following clearly marked arrows from these spaces. In general, the questions are organized by topic not necessarily in order of difficulty.
\vspace*{1cm}
\begin{tabbing}
{\Huge {\bf Your Name: }} \qquad \= {\Huge {\bf [YOUR NAME HERE]}} \\
\vspace*{0.5cm} \\
{\Huge {\bf UVa Email Id: }} \> {\Huge {\bf [YOUR EMAIL ID HERE]}} \\
\end{tabbing}
If you use any resources other than your notes page, use this space to record the time you start to use resources other than your notes page: \\
{\bf Start:} \fillinline{5cm} \qquad \qquad {\bf Stop:} \fillinline{5cm}
\newpage
\problem{Language Classification}
Classify each of the following languages as:
(R) Regular,
(CF) Context-Free, but not regular,
(TD) Turing-Decidable, but not context-free,
(TR) Turing-Recognizable, but not Turing-decidable,
or (None) None of the above.
For full credit, your answer should include a brief argument supporting your answer (but a detailed proof is not needed).
\begin{enumerate}
\item (5) The set of strings generated by the replacement grammar ($S$ is the start variable):
\begin{bnfgrammarm}{S}
\bnfrule{$S$}{$AS \mid SB$}
\bnfrule{$A$}{$0 \mid S$}
\bnfrule{$B$}{$1 \mid S$}
\end{bnfgrammarm}
\answer{Your answer here}
\item (5) $R_{TM} = \{ \langle M, w\rangle \mid M $ is a description of a TM and $w$ is not accepted by $M$ $\}$
\answer{Your answer here}
\item (5) $POWER = \{ 1^{x}**1^{y}=1^{z} \mid x, y, z \in \mathcal{N}, z = x^y \}$
\answer{Your answer here}
\item (5) {\em UVA-WINS} = $\{ y \mid y $ is a four-digit string representing a year between 2000 and 2999 and UVa wins an NCAA soccer championship (Men's or Women's) in that year $\}$
\answer{Your answer here}
%\item (5) {\em BEST-STOCK} = $\{ \langle s, d \rangle \mid s $ is a string of 1-5 alphabet characters representing a stock symbol on the NASDAQ, and $d$ is a string representing a date between April 8, 2010 and December 31, 2999, and $s$ is the NASDAQ stock with the largest percentage gain on date $d$ or $\epsilon$ if no such stock exists (e.g., the market was closed on that date or there is not stock that gained) $ \}$
\end{enumerate}
\problem{Decidability} For each subpart, answer whether or not the language is Turing-decidable. A full credit answer must include a convincing argument supporting your answer.
\begin{enumerate}
\item (10) {\em REPEATS-STATE}$_{TM} = \{ \langle M, w\rangle | M $ is a description of a TM and $M$ enters some FSM state more than once in processing input $w$. $\}$
\answer{Your answer here}
\item (10) {\em REPEATS-START}$_{TM} = \{ \langle M, w\rangle | M $ is a description of a TM and $M$ will enter $q_0$ more than once in processing input $w$. $\}$
\answer{Your answer here}
\item (10) {\em REPEATS-CONFIGURATION}$_{TM} = \{ \langle M, w\rangle | M $ is a description of a TM and $M$ will repeat some configuration in processing $w$ $\}$ \\
Hint: Recall that the configuration of a Turing machine is the entire contents of the tape, the current FSM state, and the tape head position. For full credit, your answer must include a correct reduction proof.
\answer{Your answer here}
\end{enumerate}
\problem{Language Classes}
\begin{enumerate}
\item (10) Define a {\em type of machine} that {\em recognizes} the set of languages in the \emph{Mystery Class} ellipse depicted below:
\begin{center}
\scalebox{0.3}{\includegraphics{mysteryclass.png}}
\end{center}
The machine you define should be able to recognize infinitely many Turing-recognizable languages that are not Turing-decidable but should not be able to recognize infinitely many languages that are Turing-decidable. You cannot restrict the value of $\Sigma$ (the input alphabet), but may place any other restrictions you want on the machine. A good answer will include a convincing argument why the machine you describe satisfies the requirements.
\answer{Your answer here}
\item (5) If $A$ is a Turing-recognizable language and $B \subseteq A$, is $B$ necessarily a Turing-recognizable language? (Prove or disprove.)
\answer{Your answer here}
\item (5) If $A$ and $B$ are Turing-decidable languages is the concatenation of $A$ and $B$ a Turing-decidable language? The concatenation of $A$ and $B$ is the language $\{ xy | x \in A, y \in B \}$.
(Prove or disprove.)
\answer{Your answer here}
\end{enumerate}
\problem{Janus Machine} (15) Consider a Janus Machine which is similar to a Turing machine except it has two heads which we will call the alpha and zeta heads. Initially, the alpha head starts at the left edge of the tape and the zeta head starts at the leftmost blank square (that is, one square after the end of the input). On each step, the input symbols under both heads are read, each head can a symbol on the tape, and each head can move one square left or right. Thus, the transition function for a Janus machine has three inputs and
\[
\delta: Q \times \Gamma \times \Gamma \rightarrow Q \times \Gamma \times \{ \text{\bf L, R} \} \times \Gamma \times \{ \text{\bf L, R} \}
\]
Prove that the set of languages that can be decided by a Janus Machine is identical to the set of language that can be decided by a Turing machine. (A super-full credit answer would also resolve an important ambiguity in the computing model for the Janus machine.)
\answer{Your answer here}
\problem{Fading Tape Machine} Consider a machine similar to a Turing machine, with an infinite tape, single tape head, and FSM controller, but where the symbols written on the tape are written with an ink that fades over time. The applies to both the original input written on the tape, and all symbols written on the tape by the machine.
A formal description of a Fading Tape machine is identical to that of a TM except for the addition of $K \in \mathcal{N}$, a natural number that gives the number of steps it takes for ink to fate. After $K$ steps without being written, the symbol in a square becomes indistinguishable from a blank. Note that the value of $K$ can be any natural number, but it is part of the description of the machine (that is, the value of $K$ cannot depend on the input).
We can formalize our Fading Tape machine by adding a step-counter to the machine and thinking of each write as including a time-stamp. The configuration for a Fading Tape machine is the left side of the tape (note that each tape square now contains a pair consisting of the tape symbol and time stamp), the current FSM state, the current step count, and the right side of the tape. Thus, the extended transition function for a Fading Tape machine is,
\[
\delta^{*}: (\Gamma, \mathcal{N})^{*} \times Q \times \mathcal{N} \times (\Gamma, \mathcal{N})^{*} \rightarrow (\Gamma, \mathcal{N})^{*} \times Q \times \mathcal{N} \times (\Gamma, \mathcal{N})^{*}
\]
A partial definition of $\delta^{*}$ is below (we have omitted the rules for dealing with the edge of the tape, but these are similar to the rules for a standard TM).
\begin{tabbing}
\hspace*{0.1in} \= \hspace*{0.1in} \= \hspace*{0.1in} \= \hspace*{0.1in} \= \kill
$\forall u, v \in (\Gamma, \mathcal{N})^{*}, a, b \in \Gamma, n_i \in \mathcal{N}, q \in Q$:\\
\> if $q \in \left\{q_{accept}, q_{reject}\right\}$: \\
\> \> \> $\delta^{*}(u, q_{F}, n, v) = (u, q_{F}, n, v)$\\
\> else:\\
\> \> if $\delta(q, \sqcup) = (q_r, c, \textbf{L})$ and $n_s - n_b > K$ or $b = \sqcup$:\\
\> \> \> \> $\delta^{*}(u(a, n_a), q, n_s, (b, n_b)v) = \delta^{*}(u, q_r, n_s + 1, (a, n_a)(c, 0)v)$ \\
\> \> if $\delta(q, \sqcup) = (q_r, c, \textbf{R})$ and $n_s - n_b > K$ or $b = \sqcup$:\\
\> \> \> \> $\delta^{*}(u, q, n_s, (b, n_b)v) = \delta^{*}(u(c, 0), q_r, n_s + 1, v)$ \\
\> \> if $\delta(q, b) = (q_r, c, \textbf{L})$ and $n_s - n_b \le K$:\\
\> \> \> \> $\delta^{*}(u(a, n_a), q, n_s, (b, n_b)v) = \delta^{*}(u, q_r, n_s + 1, (a, n_a)(c, 0)v)$ \\
\> \> if $\delta(q, b) = (q_r, c, \textbf{R})$ and $n_s - n_b \le K$\\
\> \> \> \> $\delta^{*}(u, q, n_s, (b, n_b)v) = \delta^{*}(u(c, 0), q_r, n_s + 1, v)$\\
\end{tabbing}
\begin{enumerate}
\item (10) To define the computing model for the Fading Tape machine, we need to specify its initial configuration. Provide a suitable description of the initial configuration to fill in the missing space in the computing model definition below.
\begin{quote}
A Fading Tape Machine $M = (Q, \Sigma, \Gamma, \delta, q_0, q_{accept}, q_{reject}, K)$
accepts a string $w \in \Sigma^{*}$ iff
\[
\delta^{*}(\text{{\em initial configuration needed}}) = (\gamma_L, q_{accept}, \gamma_R)
\]
for some $\gamma_L, \gamma_R \in (\Gamma, \mathcal{N})^{*}$.
\end{quote}
\answer{Your answer here}
\item (10) Define precisely the power of a Fading Tape machine. Support your answer with a very convincing argument.
\answer{Your answer here}
\end{enumerate}
\begin{center}
{\Large
\begin{tabular}{|c|c|c|c|c|c|} \hline
1 (20) & 2 (30) & 3 (20) & 4 (15) & 5 (20) & Total (105) \\ \hline
\qquad\qquad &\qquad\qquad &\qquad\qquad & \qquad\qquad &\qquad\qquad & \qquad\qquad \\ \hline
\end{tabular}
}
\end{center}
\end{document}