%\documentstyle[10pt,twoside]{article}
\documentstyle[twoside, 11pt]{article}
\setlength{\oddsidemargin}{0.25 in}
\setlength{\evensidemargin}{-0.25 in}
\setlength{\topmargin}{-0.6 in}
\setlength{\textwidth}{6.5 in}
\setlength{\textheight}{8.5 in}
\setlength{\headsep}{0.75 in}
\setlength{\parindent}{0 in}
\setlength{\parskip}{0.1 in}

%
% The following commands sets up the lecnum (lecture number)
% counter and make various numbering schemes work relative
% to the lecture number.
%
\newcounter{lecnum}
\renewcommand{\thepage}{\thelecnum-\arabic{page}}
\renewcommand{\thesection}{\thelecnum.\arabic{section}}
\renewcommand{\theequation}{\thelecnum.\arabic{equation}}
\renewcommand{\thefigure}{\thelecnum.\arabic{figure}}
\renewcommand{\thetable}{\thelecnum.\arabic{table}}

%
% The following macro is used to generate the header.
%
\newcommand{\problemset}[3]{
   \pagestyle{myheadings}
   \thispagestyle{plain}
   \newpage
   \setcounter{lecnum}{#1}
   \setcounter{page}{1}
   \noindent
   \begin{center}
   \framebox{
      \vbox{\vspace{2mm}
    \hbox to 6.28in { {\bf CS~151~~~Complexity Theory
                        \hfill Spring 2023} }
       \vspace{4mm}
       \hbox to 6.28in { {\Large \hfill Problem Set #1  \hfill} }
       \vspace{2mm}
       \hbox to 6.28in { {\it Out: #2 \hfill Due: #3} }
      \vspace{2mm}}
   }
   \end{center}
   \vspace*{4mm}
}

%
% Convention for citations is authors' initials followed by the year.
% For example, to cite a paper by Leighton and Maggs you would type
% \cite{LM89}, and to cite a paper by Strassen you would type \cite{S69}.
% (To avoid bibliography problems, for now we redefine the \cite command.)
%
\renewcommand{\cite}[1]{[#1]}

\input{epsf}

%Use this command for a figure; it puts a figure in wherever you want it.
%usage: \fig{NUMBER}{FIGURE-SIZE}{CAPTION}{FILENAME}
\newcommand{\fig}[4]{
            \vspace{0.2 in}
            \setlength{\epsfxsize}{#2}
            \centerline{\epsfbox{#4}}
            \begin{center}
            Figure \thelecnum.#1:~#3
            \end{center}
    }

% Use these for theorems, lemmas, proofs, etc.
\newtheorem{theorem}{Theorem}[lecnum]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}
\newenvironment{proof}{{\bf Proof:}}{\hfill\rule{2mm}{2mm}}

% Some useful equation alignment commands, borrowed from TeX
\makeatletter
\def\eqalign#1{\,\vcenter{\openup\jot\m@th
  \ialign{\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil
      \crcr#1\crcr}}\,}
\def\eqalignno#1{\displ@y \tabskip\@centering
  \halign to\displaywidth{\hfil$\displaystyle{##}$\tabskip\z@skip
    &$\displaystyle{{}##}$\hfil\tabskip\@centering
    &\llap{$##$}\tabskip\z@skip\crcr
    #1\crcr}}
\def\leqalignno#1{\displ@y \tabskip\@centering
  \halign to\displaywidth{\hfil$\displaystyle{##}$\tabskip\z@skip
    &$\displaystyle{{}##}$\hfil\tabskip\@centering
    &\kern-\displaywidth\rlap{$##$}\tabskip\displaywidth\crcr
    #1\crcr}}
\makeatother

% **** IF YOU WANT TO DEFINE ADDITIONAL MACROS FOR YOURSELF, PUT THEM HERE:


\begin{document}
\problemset{2}{April 13}{{\bf April 20}}

Reminder: you are encouraged to work in groups of two or three;
however you must turn in your own write-up and note with whom you
worked. You may consult the course notes and the optional text (Papadimitriou). The
full honor code guidelines and collaboration policy can be found in the course syllabus.


Please attempt all problems. {\bf Please turn in your solutions via
  Gradescope, by 1pm on the due date.}


\begin{enumerate}
\item A {\em strong} nondeterministic Turing Machine has, in
addition to its $q_{\mbox{accept}}$ and $q_{\mbox{reject}}$
states, a special state $q_{\mbox{?}}$. Such a Turing Machine
{\em accepts} its input if all computation paths lead to
$q_{\mbox{accept}}$ and $q_{\mbox{?}}$ states, and it {\em rejects} its
input if all computation paths lead to $q_{\mbox{reject}}$ and
$q_{\mbox{?}}$ states. Moreover, on every input, there is at least
one computation path leading to $q_{\mbox{accept}}$ or
$q_{\mbox{reject}}$. Show that the class of languages decided\footnote{A language is {\em decided} (as usual) if every input is either accepted or rejected according to the accept/reject criteria for this type of machine.} by a
strong nondeterministic Turing Machine in polynomial time is
exactly $\mbox{\bf NP} \cap \mbox{\bf coNP}$.

\item In this problem you will prove Mahaney's Theorem: a sparse
language $S$ cannot be $\mbox{{\bf NP}}$-complete unless
$\mbox{\bf P} = \mbox{\bf NP}$. Throughout this problem, $S$ is a
sparse language in $\mbox{\bf NP}$ with a polynomial bound $p(n)$
on the number of strings of length at most $n$.
\begin{enumerate}
\item Explain briefly where the proof of the special case of
Mahaney's Theorem  for {\em unary} languages (from class) breaks
down for sparse languages.

\item Show that if $\overline{\mbox{SAT}}$ reduces to $S$ in
polynomial time via reduction $R$, then a procedure very similar
to the one for unary languages from class decides
$\overline{\mbox{SAT}}$ in polynomial time, and hence implies
$\mbox{\bf P} = \mbox{\bf NP}$.

\item Define $c(n)$ to be the exact number of strings of length at
most $n$ in $S$ (clearly $c(n) \le p(n)$ for all $n$). Argue that
the following language is in $\mbox{\bf NP}$:
\[\hat{S} = \{ (x, 1^k) : k < c(|x|) \mbox{ or } (k = c(|x|) \mbox{ and } x \not\in S)\}.\]
Hint: do not try to compute $c(|x|)$; rather, focus on describing
an $\mbox{\bf NP}$ algorithm that decides $\hat{S}$ properly under
the assumption that $k = c(|x|)$, and then see what your algorithm
does when $k \ne c(|x|)$.


\item Finally we assume $S$ is $\mbox{\bf NP}$-complete. Thus,
everything in $\mbox{\bf NP}$ reduces to $S$, and we give names to
two of these reductions: let $T$ be a polynomial-time reduction
from $\mbox{SAT}$ to $S$, and let $U$ be a polynomial-time
reduction from $\hat{S}$ to $S$. Using $T$ and $U$, describe a
{\em family} of ``candidate reductions from
$\overline{\mbox{SAT}}$ to $S$,'' $R_k$, with the following
properties:
\begin{eqnarray*}
R_k(\phi) \in S && \mbox{ if $k < c(|T(\phi)|)$} \\
R_k(\phi) \in S \Leftrightarrow \phi \in
\overline{\mbox{SAT}} && \mbox{ if $k = c(|T(\phi)|)$} \\
R_k(\phi) \not\in S && \mbox{ if $k > c(|T(\phi)|)$}
\end{eqnarray*}

\item Using parts (b) and (d), prove Mahaney's Theorem. To solve a technical problem, you
may want to prove and make
use of the following lemma: 

\begin{lemma} If language $L \subseteq \Sigma^*$ is $\mbox{\bf NP}$-complete, then
language $L' \in (\Sigma \cup \{\#\})^*$ defined by
\[L' = \{x\#^i : x \in L, i \ge 0\}\]
is $\mbox{\bf NP}$-complete. If $L$ is sparse then $L'$ is sparse.
\end{lemma}
This allows one to modify the ${\bf NP}$-complete language $S$  so
that the reduction $T$, when applied to strings
of length $n$, always outputs strings of a particular length.

\item Argue that if $\mbox{\bf P} = \mbox{\bf NP}$, then there
{\em are} sparse $\mbox{\bf NP}$-complete languages (under
polynomial-time, many-one reducibility).

\end{enumerate}
\item A directed graph $G = (V, E)$ is {\em strongly connected} if
for every pair of vertices $(x, y)$ there is a directed path from
$x$ to $y$ and a directed path from $y$ to $x$. Consider STRONGLY
CONNECTED, the language of graphs $G$ that are strongly connected.
Either show that this problem is in $\mbox{\bf L}$, or prove a
complexity consequence of such a containment.

\end{enumerate}

\end{document}
