\documentclass[12pt]{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{url}
\urlstyle{sf}
\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 ``Gilligan's Island'' collaboration policy invented by Larry Ruzzo. This means:
\begin{itemize}
\item You may discuss and work on the problems with anyone you want.
\item You may not bring any written records out of your group work session. After your group discussion, you should destroy all paper notes from the meeting.
\item You may keep and use your notes from office hours, unless explicitly instructed not to.
\item You should wait at least an hour (hence the ``Gilligan's Island'' traditional name for this, although we recommend other options) after the group meeting before writing up your own solutions to make sure you understand things well enough to derive them yourself, instead of just holding them in your short-term memory.
\item You must clearly acknowledge others you worked with on the solutions you turn in.
\end{itemize}
The goal of this policy is to enable students to work with each other to explore and discuss solution ideas, and most importantly, to convince yourselves what the best solution is. But, to ensure that everyone understands everything in the assignments well enough to be able to derive it yourself. On the exams, you will be required to solve similar problems on your own, so the by following this policy on the problem sets you will be well-prepared to do well on the exams.
{\bf Resource Policy.} Some of the problems on this assignment are well known problems for which answers are readily available on the web or from previous courses. Using found solutions violates the honor expectations for this assignment --- it is detrimental to your learning the material and unfair to your fellow students. Solve the problems by thinking, not by google searching.
}}
\newcommand{\handin}[2]{
{\Large \bf Name: \fbox{\Large #1 (#2)}}
\renewcommand{\thepage}{#2-\arabic{page}}}
\newcommand{\answer}[1]{\begin{quote}\emph{Answer:} #1\end{quote}}
\begin{document}
\handout{Problem Set 1}{PS1}{2 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 the spirit of Charles Babbage.
I used my magic oracle to solve problems 1-10.
}
\newpage
\problem{Sets and Languages} For each pair of sets, $A$ and $B$ answer whether they are equal, $A \subseteq B$, $B \subseteq A$, or none of these are true. Include a brief proof supporting your answer. We use $\mathcal{N}$ and $\mathcal{Z}$ as defined in Sipser: $\mathcal{N}$ is the set of natural numbers; $\mathcal{Z}$ is the set of integers.
\begin{enumerate}
\item $ A \equiv \left\{ \right\}$, $B \equiv \left\{ \left\{ \right\} \right\}$
% Here's your free answer for using the LaTeX template! Turing this in without changes is worth full credit for this part.
\answer{{\bf $A \subseteq B$.}
$A$ is the empty set, a set containing no elements. $B$ is a set containing one element, which is an empty set. The empty set is a subset of every set.
}
\item $A$ and $B$ are sets such that $A \cup B = A \cap B$.
\answer{Your answer here}
\item $ A \equiv \mathcal{N} \times \mathcal{Z}$, $B \equiv \left\{ (i, j)\ |\ i, j \in \mathcal{N} \right\}$
\answer{Your answer here}
\item $ A \equiv \left\{ i\ |\ i \in \mathcal{Z} \wedge i \notin \mathcal{N} \right\} $ \\
$ B \equiv \left\{ i\ |\ i = -k \text{ for some } k \in \mathcal{N} \right\} $
\answer{Your answer here}
\item $ A \equiv $ the set of all binary relations that are not symmetric. \\
$ B \equiv \left\{ R\ |\ R\text{ is a binary relation and for every }x\text{ there exists a }y\text{ such that } xRy \neq yRx\right\}$
\answer{Your answer here}
\end{enumerate}
\problem{Functions} Describe three ways a Java method is different from a mathematical {\em function} (as defined in Section 0.2).
\answer{Your answer here}
\problem{Graphs and Trees} These questions are intended to check your careful understanding and precise application of the definitions in Section 0.2.
Consider the undirected graph $G = (V, E)$ where $V = \left\{1, 2, 3, 4\right\}$ and $E = V \times V$.
\begin{enumerate}
\item How long is the longest {\em simple path} in $G$?
\answer{Your answer here}
\item How many subgraphs does $G$ have?
\answer{Your answer here}
\item How many of the subgraphs of $G$ are {\em trees}?
\answer{Your answer here}
\end{enumerate}
\problem{Roshambo} [This question is seriously broken and has been
removed from this problem set. Sorry for the confusion.]
\problem{Subsets} Prove that the set subset operator ($\subseteq$) is (a) reflexive and (b) transitive, but (c) not symmetric.
\answer{Your answer here}
\problem{Powerset} Prove that the size of the powerset of any set $S$ is $2^{|S|}$. (Hint: use induction on the size of the set.)
\answer{Your answer here}
\problem{Pizza Slicing} Consider the problem of slicing a circular pizza into pieces using cuts that are straight lines all the way across the pizza. The pieces do not need to be the same size. What is the maximum number of pieces that can be cut using $n$ cuts? Support your answer with a convincing argument. (Hint: use induction.)
\answer{Your answer here}
\problem{DFAs} Draw a DFA that recognizes the language of strings in $\left\{a, b\right\}^{*}$ that do not contain any occurrences of two consecutive $a$s. For example, $\epsilon$, $abba$ and $ababbbab$ are in the language but $aa$, $baa$, and $bbabaab$ are not. Use as few states as possible.
\answer{Your answer here}
\begin{quote}
{\bf Challenge bonus:} For a given maximum length $n$, how many strings of length less than or equal to $n$ are in the language? (You are not expected to be able to solve challenge bonus problems, but will receive extra credit points for good solutions to them.)
\answer{Your answer here}
\end{quote}
\problem{Lexical Analysis} DFAs are often used in compilers to recognize lexical units in programs. Tools such as flex ({\em http://flex.sourceforge.net/}) generate code that performs lexical analysis (breaking a stream of text into a sequence of tokens) by translating regular expressions into finite state machines.
Many programming languages also provide library functions that perform scanning such as Java's {\tt java.util.Scanner} class and Python's {\tt re} library. Later in the course we will explore regular expressions and how a program might construct a DFA from a regular expression. In this problem, you will manually construct DFAs that recognize a few Java programming language constructs. For each part, your answer should be a description of a DFA that exactly recognizes the described language. You can either draw the complete DFA, or explain clearly how you would construct it.
For simplicity we assume an alphabet that is a subset of the actual Java alphabet:
\begin{quote}
$\Sigma = Letters \cup Digits \cup \left\{\text{Space}, \text{NewLine}, \text{\tt /}, \text{\tt *}\right\}$\\
$Letters = \left\{\text{\tt a}, \text{\tt b}, \text{\tt c}, \ldots, \text{\tt z}, \text{\tt A}, \text{\tt B}, \text{\tt C}, \ldots, \text{\tt Z} \right\}$\\
$Digits = \left\{\text{\tt 0}, \text{\tt 1}, \text{\tt 2}, \ldots, \text{\tt 9} \right\}$
\end{quote}
\begin{enumerate}
\item Identifiers: a sequence of one or more $Letters$ and $Digits$, the first of which must be a letter.
% for this one, its fine to just make space and hand-draw your DFAs
% to make a space, use
\answer{\vspace*{4cm}}
\item Single-line comments: a {\tt //}, followed by any number of $Letters$, $Digits$, and Space characters until a NewLine.
\answer{\vspace*{4cm}}
\item Traditional comments: {\tt /*} {\em comment} {\tt */} where {\em comment} is any element of $\Sigma^{*}$ that does not contain the substring {\tt */}. (Note that comments do not nest, so {\tt /* abcd /* // defg */} is a single comment.)
\answer{\vspace*{4cm}}
\item Any string in $\Sigma^{*}$ that does not contain a comment (of either type).
\answer{\vspace*{4cm}}
\end{enumerate}
\begin{center}
\fbox{
\parbox{5in}{
\begin{center}{\bf End of Problem Set 1.}\end{center}
Turn in your \emph{stapled} submission at the beginning of class on Tuesday, 2 February 2010.
}}
\end{center}
\end{document}