\documentclass[12pt]{article}
\usepackage{url}
\usepackage{amsmath}
\usepackage{amsfonts}

\begin{document}
% This
% ANY LATEX paper.  Typically I'll use this file and some other file in the
% directory of the paper, this one for general math things, that one for
% things specific to that paper.
%
% font's used and general paper things.
\font\tenrm=cmr10
\font\ninerm=cmr9
\font\eightrm=cmr8
\font\sevenrm=cmr7
% \font\title=cmbx10 scaled \magstep1 % extra big title font
\font\ss=cmss10 % used by \proof
\font\smallcaps=cmcsc10 % used to label Theorems, etc.
% imhibit black bars on overflows
%
\overfullrule=0pt
%
% today's date
%
%
% English words that I always italizice in papers.
% Some words that appear in math mode alot that I wasn roman
%

\newcommand{\Z}{{\mathbb Z}}
\newcommand{\N}{{\mathbb N}}
\newcommand{\Q}{{\mathbb Q}}
\newcommand{\ler}{\le_r}

\newcommand{\stt}{\mathrel{:}}
\newcommand{\el}{\ell }
\newcommand{\eltwo}{{\small \mathcal{L} }}
\newcommand{\sigp}[1]{\Sigma_{#1}^{{\rm p}}}
\newcommand{\pip}[1]{\Pi_{#1}^{{\rm p}}}
\newcommand{\sigsp}[1]{\Sigma_{#1}^{{\rm p, SPARSE}}}
\newcommand{\pisp}[1]{\Pi_{#1}^{{\rm p, SPARSE}}}
\newcommand{\Reone}{R_e^1}
\newcommand{\Retwo}{R_e^2}
\newcommand{\Rethree}{R_e^3}
\newcommand{\Reonesub}[1]{R_{\ang{e,{#1}}}^1}
\newcommand{\Retwosub}[1]{R_{\ang{e,{#1}}}^2}
\newcommand{\dom}{{\rm dom }}
\newcommand{\ran}{{\rm ran }}
\newcommand{\nd}{{\rm nd }}
\newcommand{\rd}{{\rm rd }}
%\newcommand{\th}{{\rm th }}
\newcommand{\ith}{{i}^{\rm th}}
\newcommand{\Prob}{{\rm Pr } }
\renewcommand{\Pr}{{\rm Pr } }
\newcommand{\pr}{{\rm Pr } }
\newcommand{\DTIME}{{\rm DTIME } }
\newcommand{\NTIME}{{\rm NTIME } }
\newcommand{\DSPACE}{{\rm DSPACE } }
\newcommand{\NSPACE}{{\rm NSPACE } }
%
% Commomly used Math things  MATH
%

\newcommand{\PH}{{\rm PH}}
\newcommand{\FML}{{\rm FML}}
\newcommand{\ED}{{\rm ED}}
\newcommand{\Max}{{\rm MAX}}
\newcommand{\Med}{{\rm MED}}
\newcommand{\Sort}{{\rm SORT}}
\newcommand{\Sel}{{\rm SEL}}


\newcommand{\mink}{{\rm MIN}_k}
\newcommand{\maxn}{{\rm MAX}_n}
\newcommand{\maxk}{{\rm MAX}_k}
\newcommand{\maxnm}{{\rm MAX}_{n-1}}
\newcommand{\selin}{{\rm SEL}_n^i}
\newcommand{\selina}{{\rm SELALL}_n^i}
\newcommand{\secn}{{\rm SEC}_n}
\newcommand{\medn}{{\rm MED}_n}
\newcommand{\sortn}{{\rm SORT}_n}
\newcommand{\sortk}{{\rm SORT}_k}
\newcommand{\hilon}{{\rm HI\hbox{-}LO}_n}

\newcommand{\Abar}{\overline A}
\newcommand{\Bbar}{\overline B}
\newcommand{\COFbar}{{\overline {COF}}}
\newcommand{\Kbar}{\overline K}
\newcommand{\Kleenestar}{{\textstyle *}}
\newcommand{\Kstar}{{\textstyle *}}
\newcommand{\NE}{ {\rm NE} }
\newcommand{\SPARSE}{ {\rm SPARSE} }
\newcommand{\TOTbar}{{\overline {TOT}}}
\newcommand{\Uei}{U_{\ang{e,i}}}
\newcommand{\ang}[1]{\langle#1\rangle}
\newcommand{\co}{ {\rm co} }
\newcommand{\cvg}{\downarrow}
\newcommand{\dvg}{\uparrow}
\newcommand{\ei}{\ang{e,i}}
\newcommand{\fuinv}[2]{{#1}^{\hbox{-}1}}
\renewcommand{\gets}{\leftarrow}
\newcommand{\goes}{\rightarrow}
\newcommand{\jo}{\oplus}
\newcommand{\kstar}{{\textstyle *}}
\newcommand{\move}{\vdash}
\newcommand{\penpns}{\hbox{${\rm P}={\rm NP}$}}
\newcommand{\penpq}{\hbox{P$=$?NP\ }}
\newcommand{\penp}{\hbox{P$=$NP\ }}
\newcommand{\phivec}[1]{{\ang {\phi_1,\ldots,\phi_{#1}}}}
\newcommand{\ppolyA}{{{\rm P}^A/{\rm poly}}}
\newcommand{\nppolyA}{{{\rm NP}^A/{\rm poly}}}
\newcommand{\xibar}{{\bar x_i}}
\newcommand{\xjbar}{{\bar x_j}}
\newcommand{\xkbar}{{\bar x_k}}
\newcommand{\yei}{y_{\ang{e,i}}}
\newcommand{\set}[2]{ \{ {#1}_1,\ldots,{#1}_{#2} \} }
\newcommand{\m}{{\rm m}}
\newcommand{\ctt}{{\rm ctt}}
\newcommand{\wtt}{{\rm wtt}}
\newcommand{\T}{{\rm T}}
\newcommand{\btt}{{\rm btt}}
\newcommand{\bwtt}{{\rm bwtt}}
\newcommand{\ktt}{{k\rm\mbox{-}tt}}
\newcommand{\ntt}{{n\rm\mbox{-}tt}}
\newcommand{\kwtt}{{k\rm\mbox{-}wtt}}
\newcommand{\nwtt}{{n\rm\mbox{-}wtt}}
\newcommand{\kT}{{k\rm\mbox{-}T}}
\newcommand{\onett}{{1\rm\mbox{-}tt}}
\newcommand{\leonett}{{\le_{\onett}}}
\newcommand{\eqonett}{{\equiv_{\onett}}}
\newcommand{\pTE}{\equiv_{\rm T}^p}
\newcommand{\UNIQTSP}{\rm UNIQTSP}
\newcommand{\TAUT}{{\rm TAUT}}
\newcommand{\SAT}{{\rm SAT}}
\newcommand{\usat}{{\rm UNIQSAT}}
\newcommand{\paritysat}{{\rm PARITYSAT}}
\newcommand{\LSAT}{{\rm LSAT}}
\newcommand{\R}{{\rm R}}
\renewcommand{\P}{{\rm P}}
\newcommand{\PCP}{{\rm PCP}}
\newcommand{\NP}{{\rm NP}}
\newcommand{\BPP}{{\rm BPP}}
\newcommand{\AM}{{\rm AM}}
\newcommand{\MA}{{\rm MA}}
\newcommand{\IP}{{\rm IP}}
\newcommand{\coNP}{\rm co\hbox{-}NP}
\newcommand{\QBF}{\rm QBF}
\newcommand{\PSPACE}{\rm PSPACE}
\newcommand{\alephnot}{\aleph_0}
\newcommand{\twoalephnot}{2^{\aleph_0}}
\newcommand{\lamx}[1]{\lambda x [{#1}] }
\newcommand{\bits}[1]{\{0,1\}^{{#1}}}
\newcommand{\bit}{\{0,1\}}
\newcommand{\PF}{{\rm PF}}
\newcommand{\FP}{{\rm PF}}

\newcommand{\into}{\rightarrow}
\renewcommand{\AE}{\forall^\infty}
\newcommand{\IO}{\exists^\infty}
%\newcommand{\IO}{\buildrel \infty \over \exists\!\!}
\newcommand{\ep}{\epsilon}
\newcommand{\es}{\emptyset}
\newcommand{\isom}{\simeq}
\newcommand{\nisom}{\not\simeq}

\newcommand{\lf}{\left\lfloor}
\newcommand{\rf}{\right\rfloor}
\newcommand{\lc}{\left\lceil}
\newcommand{\rc}{\right\rceil}
\newcommand{\Ceil}[1]{\left\lceil {#1}\right\rceil}
\newcommand{\ceil}[1]{\left\lceil {#1}\right\rceil}
\newcommand{\floor}[1]{\left\lfloor{#1}\right\rfloor}

%
% definitions with macros
%
\newcommand{\inter}{\cap}
\newcommand{\union}{\cup}
\newcommand{\sig}[1]{\sigma_{#1} }
\newcommand{\s}[1]{\s_{#1}}
\newcommand{\LMA}{{\rm L}(M^A)}
\newcommand{\Ah}{{\hat A}}
\newcommand{\monus}{\;\raise.5ex\hbox{{${\buildrel
    \ldotp\over{\hbox to 6pt{\hrulefill}}}$}}\;}
\newcommand{\dash}{\hbox{-}}
\newcommand{\infinity}{\infty}
\newcommand{\ie}{\hbox{ i.e.  }}
\newcommand{\eg}{\hbox{ e.g.  }}


% BEIGEL"S MACROS FOR THEOREM STUFF.
% WHEN DOING A THEOREM DO
% \begin{theorem}\label{th:NAME}
%
% WHEN DOING A LEMMA DO
%
% \begin{lemma}\label{le:NAME}
%
%
%  also works for section se, corollary co, definition de,
%  fact fa
%
%  use \ref, like
%  I will prove theorem ~\ref{th:ONE}
% 
\newcounter{savenumi}
\newenvironment{savenumerate}{\begin{enumerate}
\setcounter{enumi}{\value{savenumi}}}{\end{enumerate}
\setcounter{savenumi}{\value{enumi}}}

\newtheorem{theoremfoo}{Theorem}[section] %by chapter in report style

\newenvironment{theorem}{\pagebreak[1]\begin{theoremfoo}}{\end{theoremfoo}}

\newenvironment{repeatedtheorem}[1]{\vskip 6pt
\noindent
{\bf Theorem #1}\ \em
}{}

\newtheorem{lemmafoo}[theoremfoo]{Lemma}

\newenvironment{lemma}{\pagebreak[1]\begin{lemmafoo}}{\end{lemmafoo}}

\newtheorem{conjecturefoo}[theoremfoo]{Conjecture}

\newtheorem{research}[theoremfoo]{Line of Research}
\newenvironment{conjecture}{\pagebreak[1]\begin{conjecturefoo}}{\end{conjecturefoo}}

\newtheorem{conventionfoo}[theoremfoo]{Convention}
\newenvironment{convention}{\pagebreak[1]\begin{conventionfoo}\rm}{\end{conventionfoo}}

\newtheorem{porismfoo}[theoremfoo]{Porism}
\newenvironment{porism}{\pagebreak[1]\begin{porismfoo}\rm}{\end{porismfoo}}

\newtheorem{gamefoo}[theoremfoo]{Game}
\newenvironment{game}{\pagebreak[1]\begin{gamefoo}\rm}{\end{gamefoo}}

\newtheorem{corollaryfoo}[theoremfoo]{Corollary}
\newenvironment{corollary}{\pagebreak[1]\begin{corollaryfoo}}{\end{corollaryfoo}}

\newtheorem{claimfoo}[theoremfoo]{Claim}
\newenvironment{claim}{\pagebreak[1]\begin{claimfoo}}{\end{claimfoo}}


\newtheorem{openfoo}[theoremfoo]{Open Problem}
\newenvironment{open}{\pagebreak[1]\begin{openfoo}\rm}{\end{openfoo}}

\newtheorem{exercisefoo}{Exercise}
\newenvironment{exercise}{\pagebreak[1]\begin{exercisefoo}\rm}{\end{exercisefoo}}




\newcommand{\fig}[1] %usage:\fig{file}
{
 \begin{figure}
 \begin{center}
 \input{#1}
 \end{center}
 \end{figure}
}

\newtheorem{potanafoo}[theoremfoo]{Potential Analogue}
\newenvironment{potana}{\pagebreak[1]\begin{potanafoo}\rm}{\end{potanafoo}}

\newtheorem{notefoo}[theoremfoo]{Note}
\newenvironment{note}{\pagebreak[1]\begin{notefoo}\rm}{\end{notefoo}}

\newtheorem{notabenefoo}[theoremfoo]{Nota Bene}
\newenvironment{notabene}{\pagebreak[1]\begin{notabenefoo}\rm}{\end{notabenefoo}}

\newtheorem{nttn}[theoremfoo]{Notation}
\newenvironment{notation}{\pagebreak[1]\begin{nttn}\rm}{\end{nttn}}

\newtheorem{empttn}[theoremfoo]{Empirical Note}
\newenvironment{emp}{\pagebreak[1]\begin{empttn}\rm}{\end{empttn}}

\newtheorem{examfoo}[theoremfoo]{Example}
\newenvironment{example}{\pagebreak[1]\begin{examfoo}\rm}{\end{examfoo}}

\newtheorem{dfntn}[theoremfoo]{Def}
\newenvironment{definition}{\pagebreak[1]\begin{dfntn}\rm}{\end{dfntn}}

\newtheorem{propositionfoo}[theoremfoo]{Proposition}
\newenvironment{proposition}{\pagebreak[1]\begin{propositionfoo}}{\end{propositionfoo}}
\newenvironment{prop}{\pagebreak[1]\begin{propositionfoo}}{\end{propositionfoo}}

\newenvironment{proof}
    {\pagebreak[1]{\narrower\noindent {\bf Proof:\quad\nopagebreak}}}{\QED}
\newenvironment{sketch}
    {\pagebreak[1]{\narrower\noindent {\bf Proof sketch:\quad\nopagebreak}}}{\QED}
\newenvironment{comment}{\penalty -50 $(*$\nolinebreak\ }{\nolinebreak $*)$\linebreak[1]\ }



%\renewcommand{\labelenumi}{\roman{enumi}.}



\newenvironment{algorithm}[1]{\bigskip\noindent ALGORITHM~#1\renewcommand{\theenumii}{\arabic{enumii}}\renewcommand{\labelenumii}{Step \theenumii :}\begin{enumerate}}{\end{enumerate}END OF ALGORITHM\bigskip}

\newenvironment{protocol}[1]{\bigskip\noindent PROTOCOL~#1\renewcommand{\theenumii}{\arabic{enumii}}\renewcommand{\labelenumii}{Step \theenumii :}\begin{enumerate}}{\end{enumerate}END OF PROTOCOL\bigskip}

\newenvironment{red}[1]{\noindent REDUCTION~#1\renewcommand{\theenumii}{\arabic{enumii}}\renewcommand{\labelenumii}{Step \theenumii :}\begin{enumerate}}{\end{enumerate}END OF REDUCTION}



\newenvironment{con}{\noindent CONSTRUCTION\renewcommand{\theenumii}{\arabic{enumii}}\renewcommand{\labelenumii}{Step \theenumii :}\begin{enumerate}}{\end{enumerate}END OF CONSTRUCTION}



\newenvironment{alg}[1]{\bigskip\noindent ALGORITHM~#1\renewcommand{\theenumii}{\arabic{enumii}}\renewcommand{\labelenumii}{Step \theenumii :}\begin{enumerate}}{\end{enumerate}END OF ALGORITHM\bigskip}



\newcommand{\yyskip}{\penalty-50\vskip 5pt plus 3pt minus 2pt}
\newcommand{\blackslug}{\hbox{\hskip 1pt
        \vrule width 4pt height 8pt depth 1.5pt\hskip 1pt}}
\newcommand{\QED}{{\penalty10000\parindent 0pt\penalty10000
        \hskip 8 pt\nolinebreak\blackslug\hfill\lower 8.5pt\null}
        \par\yyskip\pagebreak[1]}

\newcommand{\BBB}{{\penalty10000\parindent 0pt\penalty10000
        \hskip 8 pt\nolinebreak\hbox{\ }\hfill\lower 8.5pt\null}
        \par\yyskip\pagebreak[1]}
     
\newcommand{\PYI}{CCR-8958528}
\newtheorem{factfoo}[theoremfoo]{Fact}
\newenvironment{fact}{\pagebreak[1]\begin{factfoo}}{\end{factfoo}}
\newenvironment{acknowledgments}{\par\vskip 6pt\footnotesize Acknowledgments.}{\par}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%% 
%%%%%%%%%%  Jim's construction macros.
%%%%%%%%%% 


%%% The follow are macros for displaying block structured programs and
%%% constructions.  Basically, they are dressed up lists, like the
%%% enumerate and itemize environments.  Use  the construction environment
%%% for the outermost ``list'' of instruction and for ``sublists'' of
%%% instructions use the block environment.  E.g., 
%%%     
%%% \begin{construction}
%%%   \item {\bf Program for} $M_{p,a}$. 
%%%   \begin{block}
%%%     \item Input $x$.
%%%     \item Instructions.  Instructions.  Instructions.  Instructions.
%%% 	      Instructions.  Instructions.  Instructions.  Instructions.
%%%     \begin{block}
%%%        \item More instructions.  More instructions.  More
%%% 		instructions.   More instructions.  
%%%        \item More instructions.  More instructions.  More
%%% 		instructions.   More instructions.  
%%%     \end{block}
%%%     \item Instructions.  Instructions.  Instructions.  Instructions.
%%%     \item Instructions.  Instructions.  Instructions.  Instructions.
%%%   \end{block}
%%%   \item {\bf End program for} $M_{p,a}$.
%%% \end{construction}


\newenvironment{construction}{\bigbreak\begin{block}}{\end{block}
    \bigbreak}

\newenvironment{block}{\begin{list}{\hbox{}}{\leftmargin 1em
    \itemindent -1em \topsep 0pt \itemsep 0pt \partopsep 0pt}}{\end{list}}


%%% If you want to label the statements/blocks in your construction,  use
%%% the lblock environment instead of the block environment and for each
%%% item macro, use \item[YOUR_LABEL].  Note that labels are
%%% do-it-yourself.
%%% 
%%% Note that in the following, the basic indentation of an lblock at
%%% level i of nesting (i>0) is (\dimen15 + i * \dimen16).  The default 
%%% value of both \dimen15 and \dimen16 is  0.75em.

\dimen15=0.75em
\dimen16=0.75em

\newcommand{\lblocklabel}[1]{\rlap{#1}\hss}

\newenvironment{lblock}{\begin{list}{}{\advance\dimen15 by \dimen16
    \leftmargin \dimen15
    \itemindent -1em
    \topsep 0pt
    \labelwidth 0pt
    \labelsep \leftmargin
    \itemsep 0pt
    \let\makelabel\lblocklabel
    \partopsep 0pt}}{\end{list}}


%%% The lconstruction is an alternative to the construction environment
%%% which lets you temporarily change the values of \dimen15 and \dimen16.

\newenvironment{lconstruction}[2]{\dimen15=#1 \dimen16=#2
  \bigbreak\begin{block}}{\end{block}\bigbreak}


\newcommand{\Comment}[1]{{\sl ($\ast$\  #1\ $\ast$)}}


%%%%%%%%%% 
%%%%%%%%%% End of Jim's construction macros.
%%%%%%%%%% 

\newcommand{\Kobler}{K\"obler}
\newcommand{\Schoning}{Sch\"oning}
\newcommand{\Toran}{Tor\'an}
\newcommand{\Balcazar}{Balc{\'a}zar}
\newcommand{\Diaz}{D\'{\i}az}
\newcommand{\Gabarro}{Gabarr{\'o}}
\newcommand{\Laszlo}{L{\'a}szl{\'o}}
\newcommand{\Erdos}{Erd\H{o}s }
\newcommand{\Erdosns}{Erd\H{o}s}
\newcommand{\Sarkozy}{S{\'a}rk{\"o}zy }
\newcommand{\Sarkozyns}{S{\'a}rk{\"o}zy}
\newcommand{\Szekely}{Sz{\'e}kely }
\newcommand{\Szekelyns}{Sz{\'e}kely}
\newcommand{\Szemeredi}{Szemer{\'e}di }
\newcommand{\Szemeredins}{Szemer{\'e}di}
\newcommand{\Holder}{H{\"o}lder }
\newcommand{\Holderns}{H{\"o}lder}
\newcommand{\Chv}{Chv{\'a}tal }
\newcommand{\Chvns}{Chv{\'a}tal}

\newcommand{\CETppn}{\C {(p+1)^n} {\es'''}}
\newcommand{\logcp}{\ceil{\log(c+1)}}
\newcommand{\plogc}{\ceil{  {{\log(c)}\over{\log(p+1)}}      }   }
\newcommand{\plogcM}{\ceil{  {{\log(c)}\over{\log(p+1)}}      }-1   }
\newcommand{\plogcp}{\ceil{  {{\log(c+1)}\over{\log(p+1)}}      }   }
\newcommand{\plogcpm}{\ceil{  {{\log(c+1)}\over{\log(p+1)}}      }-1   }
\newcommand{\plogcPM}{\ceil{  {{\log(c)}\over{\log(p+1)}}      }-1   }
\newcommand{\plogbp}{\ceil{\log_{p+1}(b+1)}}
\newcommand{\plogbpm}{\ceil{\log_{p+1}(b+1)}-1}
\newcommand{\logc}{\ceil{\log(c)}}
\newcommand{\logcpm}{\ceil{\log(c+1)}-1}
\newcommand{\FQplogcpest}{\FQ{\plogcp}{\C p \trip}}
\newcommand{\FQplogcpmX}{\FQ{\plogcp -1}{\C p X}}
\newcommand{\FQplogcpmest}{\FQ{\plogcp-1}{\C p \trip}}
\newcommand{\FQplogcest}{\FQ{\plogc}{\C p \trip}}
\newcommand{\FQplogcMest}{\FQ{\plogcM}{\C p \trip}}
\newcommand{\FQplogcpm}{\FQ{\plogcp -1}{\C p K}}
\newcommand{\FQplogcp}{\FQ{\plogcp}{\C p K}}
\newcommand{\Gehrs}{G_{s}}
\newcommand{\Gehr}{G}
\newcommand{\Gers}{G_{e,s}^r}
\newcommand{\Ger}{G_e^r}
\newcommand{\Ge}{G_e}
\newcommand{\Ghrfk}{G_{f_{k,k+1}(x)}^{hr}}
\newcommand{\Ghrf}{G_{f_{k,m}(x)}^{hr}}
\newcommand{\Gn}{G^n}
\renewcommand{\L}[1]{{\hat L}_{#1}}
\newcommand{\Lei}{L_{\ei}}
\newcommand{\Lsei}{L_{\ei}^s}
\newcommand{\Ve}{V_e}
\newcommand{\Xei}{X_{\ang{e,i}}}
\newcommand{\cGehr}{\chi(G)}
\newcommand{\cGehrs}{\chi(G_{s})}
\newcommand{\ceiling}[1]{\lc{#1}\rc}
\newcommand{\chir}{\chi^r}
\newcommand{\eoet}{\ang {e_1,e_2} }
\newcommand{\logbm}{\ceiling{\log (b-1)}}
\newcommand{\logbpm}{\logbp -1}
\newcommand{\logbp}{\ceiling{\log (b+1)}}
\newcommand{\logb}{\ceiling{\log b}}
\newcommand{\logcGehr}{\log \cGehr }
\newcommand{\logcm}{\lc \log c \rc-1}
\newcommand{\logcppm}{\lc {\log (c+1)\over p} \rc-1}
\newcommand{\logcpp}{\lc {\log (c+1)\over p} \rc}
\newcommand{\lognp}{\lc \log (n+1) \rc}
\newcommand{\logpp}{\log(p+1)}
\newcommand{\logrcGehr}{\log \rcGehr }
\newcommand{\meis}{m_{\ei}^s}
\newcommand{\mei}{m_{\ang{e,i}}}
\newcommand{\plogbm}{\ceiling{\log (b-1)\over\logpp}}
\newcommand{\plogb}{\lc {\log b\over \log (p+1)} \rc}
\newcommand{\plogcmM}{\ceiling{\log(c-1)\over\log(p+1)}-1}
\newcommand{\plogcm}{\ceiling{\log (c-1)\over\logpp}}
\newcommand{\plogcpM}{\lc{\log(c+1)\over\logpp}\rc-3}
\newcommand{\pplogcmM}{\lc{\log(c-1)-1\over p}\rc}
\newcommand{\pplogcM}{\lc{\log(c)-1\over p}\rc}
\newcommand{\pplogcm}{\lc{\log(c-1)\over p}\rc}
\newcommand{\pplogcpm}{\lc{\log(c+1)-1\over p}\rc}
\newcommand{\pplogcp}{\lc{\log(c+1)\over p}\rc}
\newcommand{\pplogcpM}{\lc{\log(c+1)\over p}\rc-1}
\newcommand{\qam}{q^{a-1}}
\newcommand{\rcGehr}{\chi^r(G)}
\newcommand{\rchi}{\chi^r}
\newcommand{\ttlogcm}{2^{\logcm}}
\newcommand{\ttlogcpm}{2^{\logcpm}}
\newcommand{\unioneinf}{\bigcup_{e=0}^{\infty}}
\newcommand{\unionsinf}{\bigcup_{s=0}^{\infty}}
\newcommand{\logsum}{{\rm logsum}}

\newcommand{\fcG}{f(\chi(G))}
\newcommand{\gcG}{g(\chi(G))}
\newcommand{\fcrG}{f(\chir(G))}
\newcommand{\gcrG}{g(\chir(G))}
\newcommand{\fpcG}{f_p(\chi(G)}
\newcommand{\gpcG}{g_p(\chi(G)}
\newcommand{\pfcG}{\fcG\over p}
\newcommand{\pgcG}{\gcG\over p}
\newcommand{\pfcrG}{\fcrG\over p}
\newcommand{\pgcrG}{\gcrG\over p}
\newcommand{\gibar}{\overline{GI}}
\newcommand{\adv}{{\rm ADV}}


\centerline{\bf Notes for CMSC 652 }
\centerline{\bf On the Number of Satisfying Assignments}
\centerline{\bf  William  Gasarch}

\section{Goal}

The work in this section is due to Valiant and Vazirani~\cite{VV}.
Our presentation is largely taken from Kobler, Schoning, Toran~\cite{gibook}.

Given a Boolean Formula we usually wonder if it has a satisfying assignment.
We look at questions about the NUMBER of satisfying assignments.

\begin{notation}
If $\phi$ is a Boolean formula then $\#(\phi)$ is the number of satisfying
assignments for $\phi$.
\end{notation}

We will concentrate on the following set:

$$\paritysat = \{ \phi \stt \#(\phi)\equiv 1 \pmod 2 \}.$$

Is $\paritysat$ easy? hard? 

Our goal is as follows:

{\it If $\paritysat\in \P$, then $\SAT$ can be solved with a 
randomized poly time algorithm.}

Since we do not think $\SAT$ can be solved with a randomized poly time algorithm,
we think $\paritysat  \notin \P$.


\section{Randomized Poly Time}

\begin{definition}
A set $A$ is in $\R$ (Randomized Polynomial Time) if there exists
a polynomial $p$, and a polynomial predicate $B$ so that for all $n$,
and for all $x$ with $|x|=n$, we have

\[
\begin{array}{rl}
x\in A &\rightarrow \Prob_{|r|=p(n)} ( B(x,r) ) \ge \frac{3}{4}\cr
x\notin A &\rightarrow \Prob_{|r|=p(n)} ( \neg B(x,r) ) =1\cr
\end{array}
\]
(Think of $r$ as being a random string.)
\end{definition}


\begin{exercise}~
\begin{enumerate}
\item
Show that if $\frac{3}{4}$ is replaced by $\frac{99}{100}$
then the resulting class is still $\R$.
\item
Show that if $\frac{3}{4}$ is replaced by $1-\frac{1}{2^{|x|}}$
then the resulting class is still $\R$.
\end{enumerate}
\end{exercise}

\begin{note}
We have defined $\R$ with 1-sided error. 
This is because most randomized algorithms
that are actually out there have 1-sided error.
Classes with 2-sided error have also been defined.
\end{note}

\begin{note}
If a problem is in $\R$, then we think of it as feasible to solve
in the real world.
This is because there
are good (though not provably good) random number generators.
There are also theoretical reasons to think that $\P=\R$
(see~\cite{NW}).
\end{note}



\begin{example}
Let DETPOLYZERO be the set of all square matrices $M(x)$ of
polynomials in one variable over the integers 
such that the $DET(M(x))\equiv 0$ (that is, for any real $a$, $DET(M(a)=0)$).
\begin{enumerate}
\item
The matrix 

$$
\begin{matrix}
x &  x-1  \\
x+1  & x^2-1 \\
\end{matrix} 
$$

is NOT in DETPOLYZERO since 

$DET(M_1(x)) = x(x^2-1)-(x-1)(x+1)= x^3-x -(x^2-1) = x^3-x^2-x+1\not\equiv 0$.

\item
The matrix

$$
\begin{matrix} 
1 &  x-1  \\
x+1  & x^2-1 \\
\end{matrix} 
$$

is IN DETPOLYZERO since the determinant is 

$DET(M_2(x)) = x^2-1 - (x-1)(x+1) = x^2-1 -(x^2-1) = 0$.

\end{enumerate}
\end{example}



Here is a randomized algorithm for DETPOLYZERO.
\begin{enumerate}
\item
Input $M(x)$ (an $n\times n$ matrix of polynomials).
\item
%BILL- make this either n to 2n^2 or something else.
Pick random primes $p_1,\ldots,p_n$ between $n^2$ and $2n^2$.
(They need not be distinct.)
\item
For each $i$, $1\le i\le n$, pick a random $a_i\in \{0,\ldots,p_i-1\}$.
\item
For each $i$, $1\le i\le n$, calculate $d_i=DET(M(a_i)) \pmod {p_i}$.
If for some $i$, $d_i\ne 0$ then
output  NO with certainty.
If for all $i$, $d_i= 0$ then output YES (not certain).
\end{enumerate}

If $M(x)\in {\rm DETPOLYZERO}$ then for all $a,p$ $M(a)\equiv 0 \pmod p$.
Hence, for all $i$, $M(a_i)\equiv 0 \pmod {p_i}$.
If $M(x)\notin {\rm DETPOLYZERO}$ then it is unlikely that $M(a)\equiv 0 \pmod p$
(we omit a formal analysis).

\begin{note}
In the above algorithm, we use ``mod $p$'' so that the intermediate
values do not get so large that computing with them is no longer polynomial
in $n$.
We pick random numbers so that
an adversary cannot contrive a bad input.
\end{note}

\begin{exercise}~
\begin{enumerate}
\item
Show that PRIMES is in $\R$.
(You may not use that PRIMES is known to be in $\P$.
You may use the Web or any other non-organic source; however,
you must hand in a reasonably complete proof.)
\item
Find a case in the literature where using randomization seems
to improve the performance of something.
\end{enumerate}
\end{exercise}


We will need the notion of a randomized reduction.

\begin{definition}
Let $A$ and $B$ be two sets.
We say that $A\ler B$ if there exists a function $f$ computable in poly time
(the reduction),  and
polynomials $p,q$ such that
\[
\begin{array}{rl}
x\in A &\rightarrow \Prob_{|r|=p(n)} (f(x,r) \in B)\ge  \frac{1}{q(n)} \cr
x\notin A &\rightarrow \Prob_{|r|=p(n)} (f(x,r) \notin B)=1 \cr
\end{array}
\]
(Think of $r$ as being a random string.)
\end{definition}

This does not look that useful since the probability of being right when $x\in A$ is  small.
But its usefulness emerges from the following theorem.

\begin{theorem}\label{th:randred}
If $A\ler B$ and $B\in \P$ then $A\in \R$.
\end{theorem}

\begin{proof}

Assume $A\ler B$ via the function $f$ and polynomials $p,q$.

\begin{enumerate}
\item
Input ($x,r)$. Let $n$ be such that $|x|=n$ and let $|r|=2p(n)q(n)$.
(We denote $r=r_1r_2\cdots r_{2q(n)}$ where, for each $i$, $|r_i|=p(n)$.)
\item
Compute $f(x,r_1)$, $\cdots$, $f(x,r_{2q(n)})$.
For each $i$ query $f(x,r_i)\in B$.
If any of the answers are YES, then output YES.
Otherwise output NO.
\end{enumerate}

If $x\notin A$ then, for all $i$, $f(x,r_i)\notin B$ hence the algorithm will (correctly) say NO.

If $x\in A$ then, for each $i$,  $\Pr(f(x,r_i)\notin B) \le (1-\frac{1}{q(n)})$.
Hence

\[
\begin{array}{rl}
[\Pr((\forall i)[f(x,r_i)\notin B])] \le & (1-\frac{1}{q(n)})^{2q(n)} \cr
                            \le & (e^{-1/q(n)})^{2q(n)} \cr
                            \le & (e^{-1})^{2} \cr
                            \le &  \frac{1}{e^2} \cr
                            \le &  \frac{1}{4}.\cr
\end{array}
\]
Hence

$\Pr((\exists i)[f(x,r_i)\in B]) \ge 1-\frac{1}{4}=\frac{3}{4}$.

This establishes the desired result.

\end{proof}

\begin{exercise}\label{ex:r}
Show that if $A\ler B$ and $B\in \R$ then $A\in \R$.
\end{exercise}

\section{Our Plan}

Given a formula $\phi$ we want to produce a formula $\phi'$ such that

\[
\begin{array}{rl}
\phi\in SAT  &\rightarrow  \#(\phi')=1 \hbox{ with high probability}; \cr
\phi\notin SAT  &\rightarrow \#(\phi')=0.\cr
\end{array}
\]

We view a formula as a set of satisfying assignments.
Hence we want to map this set to a much smaller set.
How do computer scientists map large sets to small sets?
By using Hash Functions!
The next section has all we will need.

\section{Hash Functions}

If a set is `large' then a randomly chosen hash function (which we assume is fairly uniform)
is quite likely to map some element to some fixed element.
If a set is `small' then this is unlikely.
In particular, if a random string $r$ is interpreted as a random hash function
and $A$ is large, then it is quite likely that some element of $A$ maps to $0^k$.



\begin{definition}~
\begin{enumerate}
\item
A {\it sample space} is the set of things that could happen.
In our case it will be the set of possibly hash
functions that could be produced.
\item
A {\it random variable} is a mapping from the sample space to numbers.
In our case it will be mapping the hash function $h$ to the 
number $|\{ x \mid h(x) = 0^k \}|$.
\item
If $S$ is a random variable then $E(S)$ is its expected
value and $Var(S)$ is its variance.
It is known that $Var(S)=E((S-E(S))^2) = E(S^2)-E(S)^2$.
\end{enumerate}
\end{definition}

\noindent
{\bf Important convention:} Whenever we have a 0-1 valued matrix
apply to a vector we do all of the calculations mod 2.


\begin{lemma}\label{le:prob}
Let $k,n\in\N$.
Let $X\subseteq \bits n$. Assume $0^n\notin X$.
Consider the following random variable:
Pick a random $k\times n$ 0-1 valued matrix $M$.
$$S=|\{ x\in X \stt M(x)=0^k \}|.$$
Output $S$.
Then
$E(S)=2^{-k}|X|$ and
$Var(S)\le 2^{-k}|X|$.
(Note that neither $E(S)$ nor $Var(S)$ depends on $n$, just on
$k$ and $|X|$.)
\end{lemma}

\begin{proof}
Before looking at $E(S)$ and $Var(S)$ we will need
to look at $E$ of some easier random variables


Let $x,y\in X$.
Let $R_x$ be the random variable

\begin{equation}
R_x = 
\begin{cases}
1  & \hbox{ if $M(x)=0^k$}\\
0  & \hbox{ if  $M(x)\ne 0^k$.}\\
\end{cases}
\end{equation}


Let $R_y$ be similar.

Let $M_i(x)$ be the $i$th element of the vector $M(x)$.

\[
\begin{array}{rl}
E(R_x) = & \pr(M(x)=0^k)\cdot 1 + \pr(M(x)\ne 0^k)\cdot 0; \cr
E(R_x) = & \pr(M(x)=0^k);\cr
E(R_x) = & \prod_{i=1}^k \pr(M_i(x)=0).\cr
\end{array}
\]

Recall that $x$ is fixed and that $x\ne 0^n$.
The probability that $h_i(x)=0$ can be phrased as follows:
What is the probability that a randomly chosen $y$ will make
$x\cdot y \equiv 0 \pmod 2$?
We leave it as an easy exercise that this is $\frac{1}{2}$.
Hence

$E(R_x) = \prod_{i=1}^k \pr(M_i(x)=0)= \frac{1}{2^k}$.

The exact same calculation shows that

$E(R_x^2) = \frac{1}{2^k}$.
(For any 0-1 valued random variable $Z$, $E(Z)=E(Z^2)$.)

We now compute $E(R_xR_y)$.

\[
\begin{array}{rl}
E(R_xR_y)=&\pr(M(x)=1\wedge M(y)=1)\cdot1+\pr(M(x)=0)\pr(M(y)=1)\cdot 0+\cr
          &\qquad \pr(M(x)=1)\pr(M(x)=0)\cdot 0+\pr(M(x)=0)\pr(M(x)=0)\cdot 0\cr
          = & \pr(M(x)=1)\pr(M(y)=1)\cr
          = & \frac{1}{2^k}\frac{1}{2^k} = \frac{1}{4^k}\cr
\end{array}
\]


We are now ready to tackle $E(S)$ and $Var(S)$.
Note that $S= \sum_{x\in X} R_x$.

$$E(S) = E(\sum_{x\in X} R_x) = \sum_{x\in X} E(R_x) = \frac{1}{2^k}|X|.$$

We now look at $Var(S)$. Recall that $Var(S)=E(S^2)-(E(S))^2$.

\[
\begin{array}{rl}
E(S^2) = & E((\sum_{x\in X} R_x)(\sum_{y\in X} R_y));\cr
       = & \sum_{x\in X} \sum_{y\in X} E(R_xR_y); \cr
       = & \sum_{x\in X} E(R_x^2) + \sum_{x\ne y} E(R_xR_y);\cr
       = & \sum_{x\in X} \frac{1}{2^k} + \sum_{x\ne y} \frac{1}{4^k};\cr
       = & \frac{1}{2^k}|X| +  \frac{1}{4^k}|X|(|X|-1);\cr
\end{array}
\]


\[
\begin{array}{rl}
Var(S) = & E(S^2) - (E(S))^2 \cr
        =& \frac{1}{2^k}|X| +  \frac{1}{4^k}|X|(|X|-1) - \frac{1}{4^k}|X|^2\cr
        =& \frac{1}{2^k}|X| +  \frac{1}{4^k}|X|^2- \frac{1}{4^k}|X| - \frac{1}{4^k}|X|^2\cr
        =& \frac{1}{2^k}|X| - \frac{1}{4^k}|X| \cr
        \le & \frac{1}{2^k}|X| \cr
\end{array}
\]
\end{proof}


\section{If $\paritysat\in \P$ Then $\NP=\R$}

\begin{definition}
Let $\ell\in\N$.
Then $\SAT_{\ell}$ is
$$\{ \phi \stt 1\le \#(\phi)\le \ell \}.$$
\end{definition}

We will first show $\SAT \ler \SAT_{12}$ and then
use this in our reduction $\SAT \ler \paritysat$.
The reason we use $\SAT_{12}$ (as opposed to $\SAT_{17}$ or
something else) will become evident later.

We use the following lemma which is 
Chebyshev's inequality. We do not present a proof.
\begin{lemma}
If $S$ is any random variable and $a>0$ then

$\pr( |S-E(S)| \ge a) < \frac{Var(S)}{a^2}$.
\end{lemma}

Intuitively this is saying that the probability that $S$ is far
away from $E(S)$ is small, and how small depends on $Var(S)$.

\begin{lemma}\label{le:12}
$\SAT \ler \SAT_{12}.$
\end{lemma}

\begin{proof}

Here is the randomized reduction.

\begin{enumerate}
\item
Input $\phi(\vec x)$. Let $n$ be the number of variables in $\phi$.
\item
Evaluate $\phi(\vec 0)$. If equals TRUE then output $x$ (which is a formula in $SAT_{12}$ and stop.
If FALSE then goto next step.  Note that if $X$ is the set of satisfying assignments for $\phi$
then $0^n\notin X$.
\item
Pick a random $k\in \{0,\ldots,n-1\}$ (uniformly).
\item
Pick a random $k\times n$ 0-1 valued matrix $M$.
\item
Output the Boolean formula $\psi(\vec x)=\phi(x) \wedge M(x)=0^k$. 
(This can easily be written as a Boolean formula of size poly in $n$.)
\end{enumerate}

Clearly if $\phi\notin \SAT$ then $\psi\notin \SAT_{12}$.

Assume $\phi\in \SAT$.
We show that the
$\Prob(\psi\in \SAT_{12})\ge \frac{1}{2n}$.
There are two cases.

\smallskip

\noindent
{\bf Case 1:} $\#(\phi)\le 12$. 
If $k$ is assigned to 0 at random then
$\phi=\psi\in \SAT_{12}$.
The probability that $k=0$ is $\frac{1}{n}\ge \frac{1}{2n}$.

\noindent
{\bf Case 2:} $\#(\phi)\ge 13$. 
Let $m$ be such that $2^{m} < \#(\phi)\le 2^{m+1}$.
(Note that $m\in \{3,\ldots,n-1\}$.)
We look at what happens if $k=m-2$.
(Note that $m-2 \in \{1,\ldots,n-3\}$.)
Let $X$ be the set of satisfying assignments of $\phi$.
Recall that $0^n\notin X$.
We have 
$$2^m < |X| \le 2^{m+1}.$$
We are picking a random hash function $h:\bits {n} \into \bits {k}$.
Let 
$$S=|\{ x \in X \stt h(x)=0^{k} \}|.$$
By Lemma~\ref{le:prob} we know that 
$$E(S)=2^{-k}|X| = 2^{-(m-2)}|X|$$ 
and 
$$Var(S)\le 2^{-(m-2)}|X|.$$
Hence 
$$2^{-(m-2)+m} < E(S) \le 2^{-(m-2)+m+1},$$ 
so
$$4< E(S) \le 8$$ 
and 
$$Var(S)<8.$$
We want $\Prob(S\in \{1,\ldots,12\})$.
This is $1-\Prob(S\notin \{1,\ldots,12\})$.

So what is $\Prob(S\notin \{1,\ldots,12\})$?

Note that

$S\notin \{1,\ldots,12\}$ $\rightarrow$ ($S=0) \vee (S\ge 13)$

Since $E(S)\ge 4$, $S=0$ $\rightarrow$ $|S-E(S)|\ge 4$.

Since $E(S)\le 8$, $S\ge 13$ $\rightarrow$ $|S-E(S)|\ge 5$.

Hence

$S\notin \{1,\ldots,12\}$ $\rightarrow$ $(S=0) \vee (S\ge 13)$ $\rightarrow$ $|S-E(S)|\ge 4$.

Hence

$$\Prob(S\notin \{1,\ldots,12\}) \le \Prob(|S-E(S)|\ge 4).$$

By Chebyshev's inequality 

$$\Prob(|S-E(S)|\ge 4)\le \frac{Var(S)}{4^2} \le \frac{8}{16} = \frac{1}{2}.$$

So 
$\Prob(S\in \{1,\ldots,12\})> 1-\frac{1}{2}=\frac{1}{2}$.
Hence, given that $k=m-2$ we have $\Prob(\psi \in \{1,\ldots,12\})\ge \frac{1}{2}$.
The probability that $k=m-2$ is $\frac{1}{n}$. Hence 

$\Prob(\psi \in \SAT_{12})\ge \frac{1}{2n}$.
\end{proof}

\begin{theorem}\label{th:main}
$\SAT \ler \paritysat$.
\end{theorem}

\begin{proof}

In this theorem we use capital letters for vectors of variables.
$X_1 < \cdots < X_m$ is the Boolean formula that is true iff,
in lexicographic order, $X_1 < \cdots< X_m$.


\noindent
{\bf RANDOMIZED REDUCTION}
\begin{enumerate}
\item
Input$(\phi)$.
\item
Apply the transformation from Lemma~\ref{le:12} to get a Boolean formula $\psi$.
Note that 
\[
\begin{array}{rl}
\phi\in SAT & \rightarrow \psi \in SAT_{12} \hbox{ with probability $\ge \frac{1}{2n}$};\cr
\phi\notin SAT & \rightarrow \psi \notin SAT_{12}.\cr
\end{array}
\]
\item
Pick a random $m\in \{1,\ldots,12\}$.
\item
Output 

$$\phi'=\psi(X_1)\wedge\psi(X_2)\wedge\cdots \wedge \psi(X_m) \wedge (X_1<\cdots<X_m).$$

\end{enumerate}
\noindent
{\bf END OF RANDOMIZED REDUCTION}

If $\phi\notin\SAT$ then 
$\psi\notin\SAT$ and therefore $\phi'\notin \SAT$.
Hence $\#(\phi')=0\equiv 0\pmod 2$, 
so $\phi'\notin \paritysat$.

Assume $\phi\in\SAT$.
Then then with probability $\frac{1}{2n}$, $\#(\psi)\in \{1,\ldots, 12\}$.

There are 12 cases, but we can make them all into one case.

Assume $\#(\psi)= i \in \{1,\ldots, 12\}$.
If $m=i$ then
$\psi$ has $m$ different satisfying assignments
which we order lexicographically as $B_1< \cdots <B_{m}$.
Note that $\phi'(B_1,\ldots,B_{m})$ is true, and is the only
satisfying assignment for $\phi'$.
Hence $\#(\phi')=1 \equiv 1 \pmod 2$. 
Hence if $m=i$ then $\phi'\in \paritysat$.
The probability that $m=i$ is $\frac{1}{12}$.
The probability that $\psi \in \SAT_{12}$ is $\ge \frac{1}{2n}$.
Hence the probability that $\phi'\in\paritysat$ is $\ge \frac{1}{24n}$.
\end{proof}

\begin{corollary}~
\begin{enumerate}
\item
If $\paritysat\in \P$ then $\NP=\R$.
\item
If $\paritysat\in \R$ then $\NP=\R$.
\end{enumerate}
\end{corollary}

\begin{proof}
We obtain $a$ by combining Theorem~\ref{th:randred} and \ref{th:main}.
We obtain $b$ by combining Exercise~\ref{ex:r} and \ref{th:main}.
\end{proof}



\section{Promise Problems}

The reduction from Theorem~\ref{th:main}, $SAT \ler \paritysat$,
actually showed $SAT \ler SAT_1$. 
This result is not that interesting because of the following
easy exercise.

\begin{exercise}
Show that if $SAT_1\in \P$ then $\SAT\in \P$.
\end{exercise}

Let us look at the reduction $SAT\ler SAT_1$ more carefully.

We actually have

$\phi \in \SAT \rightarrow \phi' \in SAT_1 \hbox{ probability }\ge \frac{1}{2n}$

$\phi \notin SAT \rightarrow \phi' \notin SAT$.

So if $\phi'$ is the output then, with probability $\ge \frac{1}{2n}$,  $\#(\phi')\in \{0,1\}$.

This motivates the following definition.

\begin{definition}
A {\it promise problem} is a pair $(A,PR)$
where both $A$ and $PR$ are subsets of $\Sigma^\kstar$.
$PR$ is refereed to as {\it the promise}.
The promise problem $(A,PR)$ is in $\P$ if there exists
a poly time algorithm $ALG$ such that

$PR(x)=1 \rightarrow ALG(x)=A(x)$.

Note that we do not care what $ALG(x)$ does if $PR(x)=0$.
\end{definition}

By using Theorem~\ref{th:main} and the fact that
the output $\phi'$ of the reduction satisfies (with high probability)
the promise $\#(\phi)\in \{0,1\}$, we can obtain the following.

\begin{theorem}
Let $PR(\phi)$ be the promise that $\#(\phi)\in \{0,1\}$.
If the promise problem $(SAT_1,PR)$ can be solved in $\P$
then $\NP=\R$.
\end{theorem}

\bibliographystyle{abbrv}
\bibliography{bibfile}

\end{document}

