\documentclass{article}
\usepackage{amsmath}
\input{preamble.tex}

\newcommand{\p}{{\rm P}}
\newcommand{\numberp}{{\rm \#P}}
\newcommand{\numberc}{{\rm \#C}}
\newcommand{\pspace}{{\rm PSPACE}}
\newcommand{\ph}{{\rm PH}}
\newcommand{\fp}{{\rm FP}}
\newcommand{\rp}{{\rm RP}}
\newcommand{\bp}{{\rm BP}}
\newcommand{\plog}{{\rm P/log}}
\newcommand{\np}{{\rm NP}}
\newcommand{\sat}{{\rm SAT}}
\newcommand{\true}{{\rm TRUE}}
\newcommand{\false}{{\rm FALSE}}
\newcommand{\conp}{{\rm coNP}}
\newcommand{\C}{{\cal C}}
\begin{document}

\lecture{9}{March 2, 2000}{Dan Spielman}{Abie Flaxman}

At the end of last lecture, we defined the complexity class \numberp.
In today's lecture we will identify some \numberp-complete problems.  We
will also begin a proof of Toda's theorem, which shows that $\ph
\subseteq \p^\numberp$.

\section{\numberp-completeness}
\begin{definition}
$\numberp$ is the set of functions $f$ for which there exists a
polynomial time, nondeterministic Turing Machine $M$ such that $f(x)$
is the number of accepting paths of $M$ on input $x$.
\end{definition}

\begin{definition}
$\fp$ is the set of functions computable in polynomial time.
\end{definition}

\begin{definition}
A function $f$ is called {\it \numberp-complete} if 
\begin{enumerate}
\item $f \in \numberp,$
\item For all $g \in \numberp, g \in \fp^f.$
\end{enumerate}

\end{definition}

Let \#CIRCUIT-SAT be the function that associates every circuit with the
number of inputs that cause the circuit to output \true.
\begin{claim}
{\rm \#CIRCUIT-SAT} is \numberp-complete.
\end{claim}

\begin{proof}
\#CIRCUIT-SAT is clearly in \numberp.  The meat of the proof is
verifying condition (2).  Let $M$ be a polynomial time,
nondeterministic Turing Machine.  Consider its computation tableau.
We outlined in a previous lecture how to turn the tableau into a
circuit.  Do this.  To count the number of accepting paths $M$ has on
input $x$, hardwire $x$ as the input to the circuit for $M$, and make
the actual input to the circuit the branch direction at each
nondeterministic operation.  This circuit will output \true{} for every
accepting path of $M$ on $x$.
\end{proof}

Let \#SAT be the function that associates every boolean function $\phi$
with the number of assignments that satisfy $\phi$.
\begin{claim}
{\rm \#SAT} is \numberp-complete.
\end{claim}

\begin{proof}
Given a circuit $C$ with input $\bar{x}$, construct a 3CNF $\phi$ with
inputs $(\bar{x}, \bar{y})$ such that if $\bar{x}$ satisfies $C$,
there exists a unique $\bar{y}$ such that $(\bar{x}, \bar{y})$
satisfies $\phi$.  This construction requires one variable for each
gate and a small number of clauses allowing only legal configurations
of each gate.
\end{proof}

\begin{remark}
These reductions have exactly as many accepting paths as the original
problem.  Why don't we strengthen the definition of
\numberp-completeness to reflect this?

The answer is that \#MATCHINGS (also known as PERMANENT) is
\numberp-complete only under our current definition.  Given an
instance of \#SAT with $c$ clauses and $S$ satisfying assignments, you
get a graph with something like $4^cS$ matchings.  (But definitely not
exactly this...)

Finding a matching (or even a bunch of matchings) is a polynomial time
operation.  So this is pretty weird.  Especially considering our next
theorem, which shows that $\numberp$ is at least as powerful as \ph.
\end{remark}

\section{Machinary for Toda's Theorem}
\begin{theorem}
(Toda's Theorem) $\ph \subseteq \p^\numberp$
\end{theorem}

\begin{flushright}
\begin{tabular}{ll}
Question:&Is $\p^\numberp \subseteq \pspace$?\\
Answer:&Yes.
\end{tabular}
\end{flushright}

To get an intuition for Toda's theorem, we need to define some new
complexity classes.  For class $\C$, we will define four class
operators.  We can use these to get all kinds of new classes.

\begin{definition}
$\Sigma \cdot \C$ is the set of all $L$ for which there exists a
polynomial $p(n)$ and a language $A \in \C$ such that $x \in L$ iff
there exists $y, |y| = p(|x|)$ such that $(x,y) \in A.$
\end{definition}

\begin{definition}
$\Pi \cdot \C$ is the set of all $L$ for which there exists a
polynomial $p(n)$ and a language $A \in \C$ such that $x \in L$ iff
for all $y, |y| = p(|x|)$, $(x,y) \in A.$
\end{definition}

\begin{definition}
$\bp \cdot \C$ is the set of all $L$ for which there exists a
polynomial $p(n)$ and a language $A \in \C$ such that
\begin{enumerate}
\item $x \in L \Rightarrow \Pr_{|y|=p(|x|)} \limits [(x,y) \in A] > 2/3$
\item $x \notin L \Rightarrow \Pr_{|y|=p(|x|)} \limits [(x,y) \in A] < 1/3$
\end{enumerate}
\end{definition}

\begin{definition}
{\rm (Parity operator)} $\oplus \cdot \C$ is the set of all $L$ for
which there exists a polynomial $p(n)$ and a language $A \in \C$ such
that $x \in L$ iff $|\{y$ s.t. $|y| = p(|x|)$, $(x,y) \in A\}|$ is
odd.
\end{definition}

Using these class operators, we can state the key elements of
Toda's theorem.

\begin{claim}
$\np \subseteq \bp \cdot \oplus \cdot \p,$
and more generally,
$\Sigma_k^P \subseteq (\bp \cdot \oplus)^k \cdot \p$.
\end{claim}

\begin{claim}
For any class $\C$ formed by applying these operators to \p,
\begin{eqnarray*}
\oplus \cdot \bp \cdot \C &\subseteq& \bp \cdot \oplus \cdot \C,\\
\oplus \cdot \oplus \cdot \C &\subseteq& \oplus \cdot \C,\\
\bp \cdot \bp \cdot \C &\subseteq& \bp \cdot \C,\\
\bp \cdot \oplus \cdot \p &\subseteq& \p^\numberp.
\end{eqnarray*}
\end{claim}

This may look like operator soup, but it's going to pay off.

We're not going to prove the boldest of these claims directly, but we
will do some of the special cases.

\begin{lemma}
$\np \subseteq \bp \cdot \oplus \cdot \p$
\end{lemma}

\begin{proof}
Recall the theorem of Valiant and Vazirani from last lecture: there
exists a random polynomial time procedure that takes a circuit $C$ and
returns $n+1$ circuits $C_1, ..., C_{n+1}$ such that if $C$ is
satistfiable, $$\Pr[\text{there exists } i \text{ s.t. } C_i \text{
has exactly one satisfying assignment}] > 1/8,$$ and otherwise no
$C_i$ has a satisfying assignment.

Two things are not so good about this.  First, the $1/8$ should be a
$2/3$.  Second, we have $n+1$ circuits and we want to have 1.

To circumvent objection 1, we amplify the probability by repetition.
Say we output $C_1^i, ..., C_{n+1}^i$ for $i = 1, 2, ..., 20$.  Then
$$\Pr[\text{exists } i, j \text{ s.t. } C_j^i \text{ has exactly one
satisfying assignment}] > 1 - (7/8)^{20} \approx 0.930.$$

How can we beat objection 2?  We do something like ``AND them all
togther'' (but not quite, because that doesn't work.)

Given $x_1, ..., x_n$, if there exists $i$ such that $x_i$ is even,
then $\prod x_i$ is even.  If there exists $i$ such that $x_i$ is odd,
then $1+\prod (1+x_i)$ is odd.  This is our inspiration.

Given $C_1(\bar{x}_1)$ has $m_1$ satisfying assignments and
$C_2(\bar{x}_2)$ has $m_2$ satisfying assignements, $C_1 \cap
C_2(\bar{x}_1, \bar{x}_2)$ has $m_1 m_2$ satisfying assignments.

It is easy to add one: given a circuit $C$ with $m$ satisfying
assignments, we form a new circuit $C'$ with $m+1$ satisfying
assignments by adding an additional input, $z$, with the rule that if
$z=0$, $C'$ does what $C$ would do, and if $z=1$, $C'$ accepts only if
$x_1, ..., x_n$ are all 1.

So we have a randomized polynomial time procedure which takes a
circuit $C$ as input and outputs a circuit $C'$ such that:
\begin{enumerate}
\item if $\numberc > 0, \Pr[\numberc' \text{ is odd}] > 2/3$
\item if $\numberc = 0, \numberc'$ is even.
\end{enumerate}

This gives us a $\bp \cdot \oplus \cdot \p$ algorithm for recognizing
the \np-complete language CIRCUIT-SAT.  $C$ is in CIRCUIT-SAT iff for
most choices of random bits $C'$ has an odd number of satisfying
assignments.
\end{proof}

\begin{flushright}
\begin{tabular}{ll}
Question:&Why did we use $\bp$ and not \rp?\\
Answer:&Here $\rp$ would have worked also, but perhaps not for
$\Sigma^P_k.$
\end{tabular}
\end{flushright}

\begin{observation}
$\bp \cdot \oplus \cdot \p$ is closed under compliment because $\oplus
\cdot \p$ is closed under compliment.
\end{observation}

\begin{corollary}
$\conp \subseteq \bp \cdot \oplus \cdot \p$
\end{corollary}

A similar technique would prove $(\Pi\cdot\Sigma)^k\cdot \p \subseteq
(\bp \cdot \oplus)^k\cdot\p$, but the bookkeeping is nasty, so we will
develop more machinary and come back to this.

\begin{theorem}
$\oplus \cdot \bp \cdot \p \subseteq \bp \cdot \oplus \cdot \p$
\end{theorem}

\begin{proof}
Let $L$ be a language in $\oplus \cdot \bp \cdot \p$.  Then there is a
polynomial $p_1(n)$ and some language $A' \in \bp \cdot \p$ such that
$x \in L$ iff $(x,y) \in A'$ for an odd number of $y$'s with length
$p_1(|x|).$

We will amplify the error probabilities of the $\bp$ operator so the
error is less than $2^{-2p_1(|x|)}$.  Then there is a polynomial
$p_2(n)$ and some language $A \in \p$ such that
\begin{enumerate}
\item $(x,y) \in A' \Rightarrow \Pr_{|z|=p_2(|(x,y)|)} \limits
[(x,y,z) \in A] > 1-2^{-2p_1(|x|)}$
\item $(x,y) \notin A' \Rightarrow \Pr_{|z|=p_2(|(x,y|)} \limits
[(x,y,z) \in A] < 2^{-2p_1(|x|)}$
\end{enumerate}

Putting these definitions togther, we see that
$$x \in L \Rightarrow \Pr_z[(x,y,z) \in A] > 1-2^{2p_1(|x|)} \text{
for an odd number of $y$}.$$ Also,
$$x \notin L \Rightarrow \Pr_z[(x,y,z) \in A] > 1-2^{2p_1(|x|)} \text{ for an even number of
$y$}.$$

And for any y, $$\Pr_z[(x,y,z) \in A \text{ disagrees with } (x,y) \in A'] <
2^{2p_1(|x|)}.$$

So, $$\Pr_z[(x,y,z) \in A \text{ agrees with } (x,y) \in A' \text{ for
all } y] < 2^{2p_1(|x|)}\cdot2^{p_1(|x|)} = 2^{p_1(|x|)}.$$

Therefore, $$x \in L \Rightarrow \Pr_z[(x,y,z) \in A \text{ for an odd
number of } y] > 1 - 2^{-p_1(|x|)}$$ and $$x \notin L \Rightarrow
\Pr_z[(x,y,z) \in A \text{ for an odd number of $y$}] <
2^{-p_1(|x|)}.$$
\end{proof}
\end{document}

