%\documentstyle[10pt,twoside]{article}
\documentstyle[twoside, 11pt,amsfonts]{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:

\newcommand\qp{{\mathop\textup{quasipoly}}}
\newcommand\poly{{\mathop\textup{poly}}}
\newcommand\Z{{\mathbb{Z}}}
\newcommand\F{{\mathbb{F}}}

\begin{document}
\problemset{7}{May 25}{{\bf June 1}}


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 Linearity Testing. Let $f:\F_2^n \rightarrow \F_2$ be a function, and suppose that
\begin{equation}
\label{eq:lin-test}
\Pr_{x,y}[f(x) + f(y) = f(x+y)] \ge 1 - \delta,
\end{equation}
where $x,y$ are chosen uniformly in $\F_2^n$. Define $\tilde{f}:\F_2^n
\rightarrow \F_2$ by \[\tilde{f}(x) = \mbox{majority}_y (f(x+y) -
f(y)),\]
where we set $\tilde{f}(x) = 0$ if there is a tie.
\begin{enumerate}
\item Prove that for all $x \in \F_2^n$, we have \[\Pr_y[f(x+y) - f(y)
  = \tilde{f}(x)] \ge 1 - 4\delta.\] Hint: start by relating the probability that
  the a random voter disagrees with the majority to the probability
  that two random voters disagree.


\item Show that $\Pr_x[f(x) \ne \tilde{f}(x)] \le 2\delta$. Hint: use
   Eq. (\ref{eq:lin-test}) and the definition of $\tilde{f}$.


\item Assume that $\delta < 1/14$. Prove that $\tilde{f}$ is linear;
  i.e., for all $x, y$ we have \[\tilde{f}(x) + \tilde{f}(y) =
  \tilde{f}(x+y).\] Hint: Eq. (\ref{eq:lin-test}) gives us
\begin{eqnarray*}
\Pr_{w,z}[f(w) + f(z) = f(w+z)] & \ge & 1 - \delta \\
\Pr_{w,z}[f(x+w) + f(y+z) = f(x+y+w+z)] & \ge & 1 - \delta.
\end{eqnarray*}
Now use part (a) to obtain statements about
$\tilde{f}(x)$, $\tilde{f}(y)$ and $\tilde{f}(x+y)$.


\item Given a function $f:\F_2^n \rightarrow
  \F$, the BLR linearity test on $f$ is the following
  procedure: pick $x,y \in \F_2^n$ randomly; $f$ passes the test if $f(x) + f(y)
  = f(x+y)$. Prove the following two statements:
\begin{description}
\item[Completeness:] If $f$ is linear, then $f$ passes the test with
  probability 1.
\item[Soundness:] If $f$ passes the test with probability $1 -
  \delta$, then there exists a {\em linear} function $\tilde{f}$
  satisfying $\Pr_x[f(x) = \tilde{f}(x)] \ge 1 - O(\delta)$.
\end{description}


\end{enumerate}




\item Recall that a {\em clique} in an undirected graph $G = (V,
E)$ is a subset $V' \subseteq V$ with edges between every pair of
vertices in $V'$. We know that the language \[\mbox{CLIQUE} =
\{(G, k) : \mbox{$G$ has a clique of size $k$}\}\] is $\mbox{\bf
NP}$-complete. You will show that there is some constant $\delta >
0$ for which CLIQUE is $\mbox{\bf NP}$-hard to approximate to
within $N^\delta$ in the following sense: if there is an
$N^\delta$-approximation algorithm for CLIQUE, then $\mbox{\bf NP}
= \mbox{\bf ZPP}$. Here $N$ is the length of the input $(G, k)$.

The PCP Theorem implies that there is some constant $\epsilon > 0$
for which given a 3-CNF formula $\phi$ it is $\mbox{\bf NP}$-hard
to distinguish between the following two cases:
\begin{eqnarray*}
\mbox{YES} & : & \mbox{$\phi$ is satisfiable} \\
\mbox{NO} & : & \mbox{every assignment to $\phi$ satisfies at most
a $(1 - \epsilon)$ fraction of the clauses}
\end{eqnarray*}
Below you will describe a {\em randomized} transformation from an
instance $\phi$ into a graph $G$ whose intended effect is that a
YES instance produces a graph with a large clique, while a NO
instance produces a graph with only a very small clique. Here $n$
is the number of variables in $\phi$.

\begin{enumerate}
\item Suppose $\phi$ is a NO instance, and consider the following
probabilistic experiment: pick $\log_2 n$ clauses from $\phi$
uniformly at random, take their conjunction, and call this CNF
$\phi_1$; repeat $n^3$ times to get CNFs $\phi_1, \phi_2, \ldots,
\phi_{n^3}$. Show that for a fixed assignment $A$:
\[\Pr[\mbox{$A$ satisfies at least $n^{3 - \epsilon}$ of the $\phi_i$}] < e^{-n^2}.\]
Hint: What is the probability that $A$ satisfies a given $\phi_i$?
What is the expected number of $\phi_i$ satisfied by $A$? You may
want to use the fact that $(1 - \epsilon)^{1/\epsilon} \le 1/e$
for $1 > \epsilon > 0$, and the Chernoff bound: if $X$ is the sum
of independent 0/1 random variables with expected value
$\mbox{E}[X] \le \mu$, then $\Pr[X > 2\mu] \le e^{-\mu/3}$.

\item Argue that the above randomized procedure produces from
$\phi$ a collection of 3-CNFs $\phi_1, \phi_2, \ldots, \phi_{n^3}$
for which
\begin{enumerate}
\item $\phi$ is a YES instance $\Rightarrow \Pr[\mbox{$\exists$
assignment $A$ simultaneously satisfying all of the $\phi_i$}] =
1$, and

\item $\phi$ is a NO instance $\Rightarrow \Pr[\mbox{no assignment
satisfies more than $n^{3 - \epsilon}$ of the $\phi_i$}] \ge 1/2.$
\end{enumerate}

\item Describe an efficient deterministic procedure to construct a
graph $G$ from the collection of 3-CNFs in part (b) for which
\begin{enumerate}
\item $\exists$ assignment $A$ simultaneously satisfying all of
the $\phi_i  \Rightarrow G$ has a clique of size $n^3$, and

\item no assignment satisfies more than $n^{3 - \epsilon}$ of the
$\phi_i \Rightarrow$ no clique in $G$ has size greater than $n^{3
- \epsilon}$.
\end{enumerate}

\item Prove that there exists a constant $\delta > 0$ for which an
$N^\delta$-approximation algorithm for CLIQUE implies that
$\mbox{\bf NP} = \mbox{\bf ZPP}$, where $N$ is the length of the
input.
\end{enumerate}

\item {\bf Optional for extra credit}. This problem concerns the circuit class $\mbox{\bf ACC}$: polynomial-sized, constant-depth circuits with unbounded fan-in AND and OR gates, NOT gates, and unbounded fan-in MOD-$m$ gates, which output $1$ iff the number of true inputs to the gate is divisible by $m$. This appears to be a very weak class (e.g., without the MOD-$m$ gates, it is known that it incapable of even computing the parity function). However, until late 2010, no one knew how to prove that $\mbox{\bf NEXP}$ is not in $\mbox{\bf ACC}$! This problem follows Ryan William's breakthrough result that finally shows that $\mbox{\bf NEXP}$ is not in $\mbox{\bf ACC}$. You will prove the slightly easier statement that $\mbox{\bf E}^{\mbox{\bf NP}}$ is not in $\mbox{\bf ACC}$, which contains all of the main ideas. Recall that $\mbox{\bf E} = \cup_{k \ge 1} \mbox{\bf TIME}(2^{kn})$.


\begin{enumerate}

\item We say ``$\mbox{\bf ACC}$-type circuit'' to mean a constant-depth circuit with the same allowed gates as for $\mbox{\bf ACC}$, but not necessarily polynomial-size. We use $\qp(n)$ as shorthand for $2^{\log^{O(1)} n}$. Using the following theorem, show how to obtain a list of {\em all} evaluations of an $\mbox{\bf ACC}$-type circuit $C$ with $n$ inputs in time $O(2^n\cdot \poly(n, \log |C|) + \qp(|C|))$. Note this is much better than the $O(2^n\cdot |C|)$ running time of the obvious algorithm when $|C|$ is large.

    \begin{theorem}
    Given an $\mbox{\bf ACC}$-type circuit $C$, there is a deterministic procedure running in time $O(\qp(|C|) + 2^n\cdot \poly(n))$ that produces from $C$ a multilinear polynomial $f$ with nonnegative coefficients (presented as a vector of $2^n$ coefficients) and a poly-time computable function $T:\{0,1,\ldots, \ell\} \rightarrow \{0,1\}$, with $\ell \le \qp(|C|)$, such that C(x) = T(f(x)). Here we are identifying Boolean values FALSE and TRUE with $0,1 \in \Z$.
    \end{theorem}

    Hint: First compute $f(x)$ for all $x \in \{0,1\}^n$ with $O(n2^n)$ arithmetic operations using a divide and conquer algorithm.

\item Give a deterministic algorithm that is given an $\mbox{\bf ACC}$ circuit $C$ with $n$ inputs and determines if it is satisfiable in time $O(2^{n - n^\delta})$ for some constant $\delta > 0$. Hint: plug in all possible values for the first $n' < n$ variables to form new $\mbox{\bf ACC}$-type circuit.

\item We know from Lecture 2 that {\sc succinct 3-sat} is $\mbox{\bf NEXP}$-complete. A more careful reduction gives the following: for every language $L \in \mbox{\bf NTIME}(2^n)$, there is a reduction from $L$ to {\sc succinct 3-sat} mapping instances $x$ of length $n$ to circuits $C_x$ of polynomial size, with $m = n + 5\log n$ inputs. Such a circuit succinctly encodes a 3-SAT formula $\phi_x$ of length $2^m$.

    Show that if $\mbox{\bf E}^{\mbox{\bf NP}} \subseteq \mbox{\bf ACC}$, then {\sc succinct 3-sat} has {\em succinct witnesses}: for every $x \in L$, there is an $\mbox{\bf ACC}$ circuit $W_x$ such that assigning the $i$-th variable in $\phi_x$ the value $W_x(i)$ satisfies $\phi_x$.

\item Show that if $\mbox{\bf E}^{\mbox{\bf NP}} \subseteq \mbox{\bf ACC}$, then every language $L \in \mbox{\bf NTIME}(2^n)$ can be simulated in $\mbox{\bf NTIME}(2^{n - n^\delta}$) for some constant $\delta > 0$, contradicting the $\mbox{\bf NTIME}$ hierarchy.

    Hint: given the circuit $C_x$ from the previous part, guess \mbox{\bf ACC} circuits $D$ (intended to be equivalent to $C_x$), $G$ (intended to encode $C_x$ gate by gate -- i.e., given the index of a gate, it output the type of gate, and the indices of its at most $2$ inputs), $V$ (intended to encode the gate-by-gate evaluation of $C_x$ -- i.e., given an input $z$ and the index of a gate, it output that gate's value when $C_x$ is evaluated on $z$) and $W_x$ (intended to be a succinct witness for $\phi_x$). Use part (b) twice, once to verify that $D$ is equivalent to $C_x$ (using $G$ and $V$ to express this equivalence using only \mbox{\bf ACC} circuits) and once to verify that $W_x$ encodes a satisfying assignment to $\phi_x$.

\end{enumerate}


\end{enumerate}

% If you need to add references, use the following format:

%\section*{References}
%
%\begin{itemize}
%\item[CW87] {\sc D.~Coppersmith} and {\sc S.~Winograd},
%Matrix multiplication via arithmetic progressions,
%{\it Proceedings of the 19th ACM Symposium on Theory of Computing},
%1987, pp.~1--6.
%
%\item[S69] {\sc V.~Strassen}, Gaussian Elimination Is Not Optimal,
%{\it Numerische Mathematik\/~\bf13}, 1969, pp.~354--356.
%
%\item[P84] {\sc V.~Pan}, {\it How To Multiply Matrices Faster},
%Springer-Verlag, Lecture Notes in Computer Science Vol.~179, 1984.
%
%\end{itemize}

\end{document}
