\documentstyle[12pt,twoside,amssymb]{article}
\input{defs-6045}

%\input{/th/u/meyer/6045/6045-spring-89/defs-6045}
\def\implies{\mbox{ implies }}
\renewcommand{\mid}{:}
\def\Ic{\mathify{\{c,I\}}}
\def\Kt{K_{\rm tot}}
\def\TIME{{\rm TIME}}
\def\NTIME{{\rm NTIME}}
\def\GSAT{{\rm GSAT}}
\def\jump#1{^{(#1)}}
\def\parens#1{\left( #1 \right)}
\newcommand{\poly}{{\Bbb P}}
\newcommand{\nat}{{\Bbb N}}
\newcommand{\npoly}{{\Bbb NP}}

\begin{document}

\handout{Supp-reading-3}{Supplementary Reading Material-3}{April 22, 1992}

\bigskip

This is the following of the complexity lecture notes that you received in Handout~33.
These notes were prepared 
 by Professors
Bui, Cosmodakis, Leiserson,  Meyer, Sipser, Sur and Weiss.
We will   supplement them as usual with additional material as the class
progresses.
\bigskip


\section{ Nondeterministic Polynomial Time}
\label{secNP}

\begin{definition} Let $L$ be a language, $T$ be a function from $\nat$
to $\nat$, and $M$ be a nondeterministic TM.  We say that {\it $M$
accepts $L$ in time $T$} if and only if $M$ accepts $L$, and for every
$w \in L$, there is an accepting computation of $M$ on input $w$ with at
most $T(|w|)$ steps.

$$\NTIME(T) := \{L:\; L \mbox{ is accepted by some nondeterministic TM in time }
T\}$$
\end{definition}
%	COMMENTED OUT BY ISAAC:
%\note{ This definition
%differs from the one in L\&P.  The two definitions can be shown to coincide for
%step-counting functions $T$.  Our definition has the advantage that,
%as for deterministic TIME, we have NTIME$(T) = \NTIME (O(T))$ for all
%$T$ such that $T(n) \geq (1+\epsilon)n$.}

Since a deterministic Turing machine may also be considered to
be nondeterministic, we have the trivial relationship $\TIME(T) \subseteq
\NTIME(T)$ for all $T$.  Less trivial is the relationship

\begin{lemma} $\NTIME(T) \subseteq \cup_{r>1} \TIME(r^T)$.
\end{lemma}

\begin{proof}The idea is that if $L \in \NTIME(T)$, then $L$
is accepted by some nondeterministic Turing machine $M$ which accepts
$w\in L$ in no more than $T(|w|)$ steps.  By enumerating each possible
computation of $M$ on input $w$ for $T(|w|)$ steps, a deterministic
Turing machine can check whether $w$ is in the language.  The time
required by the deterministic machine is $r^{T(|w|)}$ steps, where
$r$ is a constant that depends on $M$. We also need to add in the time
required to compute the bound $T(|w|)$ itself but this is $O(T(|w|))$
by hypothesis. 
\end{proof}


Let
$${\npoly}:= \bigcup_{k\geq 1} \NTIME(n^k).$$
The class $\npoly$ is, like $\poly$, invariant under variations in
computer models. It plays a technical role in complexity theory
analogous to the role of r.e. sets in computability theory,
but the analogy is not perfect.  For example, it is not known whether
${\poly} = {\npoly}\cap \hbox{co--}{\npoly}$ (remember, recursive =
r.e. $\cap$ co-r.e.), or even whether ${\poly} \not = {\npoly}$.  The
significance of this last question, 
which is often regarded as the {\em most
important open problem in theoretical
computer science}, will become apparent below.

Just as recursive enumerability inherits downward under $\leq_m$,
membership in $\npoly$ inherits downward under $\leq_p$.

\begin{lemma} If $A \leq_p B$ and $B \in \npoly$, then $A \in
\npoly$.
\end{lemma}

\begin{proof} Easy. 
\end{proof}

Many familiar computational problems are in $\npoly$, in particular
COMPOSITE, GSAT, 3SAT, VC, CLIQUE, HAMC, and TSP are in $\npoly$.
This follows in each case from the existence of a straightforward
procedure which nondeterministically chooses a truth assignment,
subset of vertices, or ordering of the vertices of a graph and then 
verifies in polynomial time that the choices produced a satisfying
assignment, a cover or clique of the desired size, or is a circuit
through the graph of the desired kind.

\noindent{\bf Exercise:} Describe in more detail the nondeterministic
polynomial-time procedure which accepts (1) GSAT, (2) COMPOSITE.

It was a remarkable insight of S. Cook, and independently L. Levin, to
realize that among all the problems in $\npoly$, the GSAT problem is
the ``hardest'' in the sense that GSAT is $\npoly$-complete.

\begin{theorem}{\bf (Cook)} GSAT is $\npoly$-complete.
\end{theorem}

Before proving the theorem, let's observe a few of its consequences.  
First, each of the problems noted to be in $\npoly$ is
reducible to GSAT.  For example, Cook's theorem implies that
CLIQUE $\leq_p$ GSAT, a rather surprising fact since there
is no obvious relationship between cliques in graphs and satisfiable 
Boolean formulas.  Also, we have from the lemma above that 

\begin{corollary} GSAT $\in\poly$ iff $\poly=\npoly$.
\end{corollary}

\begin{corollary} GSAT $\in\poly$ implies CLIQUE,
  COMPOSITE, VC, $\ldots$ are all in $\poly$.
\end{corollary}

\begin{proof}
{\bf (Cook's Theorem)} We shall do this by exhibiting for any
$L \in \npoly$ a polynomial-time computable function $f_L$ from
strings to Boolean formulas such that for any string $w$:

$$ w\in L \iff f_L(w) \hbox{ is satisfiable.}$$

Assume that $L$ is a language in $\npoly$, in which case $L$ is
accepted in polynomial time by some nondeterministic TM $M =
(K,\Sigma,\Gamma,s,\delta)$: in these notations $K$ is the set
of states and the initial state is $s$.  Also to simplify matters
we will take $\Gamma = \Sigma$. By invariance of $\poly$,
we may assume that $M$ satisfies the following restrictions:
\begin{enumerate}
\item The machine $M$ has only one tape and only one read/write head.
\item When $M$ is about to accept, it first moves its head to the
leftmost square of its tape and then halts.  
\item If $M$
enters a halted configuration, then $M$'s configuration for subsequent
time steps remains the halted configuration.
\item In any move of $M$:
	\begin{enumerate}
	\item If $M$ changes the symbol currently scanned,
	the head then stays where it is.
	In this case we will
	write that $(q',\sigma') \in \delta(q,\sigma)$ to signify that
	the move where	the head stays in the same location,
	 with the state changing from
	$q$ to $q'$, and the currently scanned symbol changing
	from $\sigma$ to $\sigma'$
	 is a legal (non-deterministic) move.
	\item If the head moves left or right then $M$ leaves
	unchanged the symbol currently scanned. In this case we will
	write that $(q',L) \in \delta(q,\sigma)$ to signify that
	the move where	the head moves left with the state changing from
	$q$ to $q'$ is a legal (non-deterministic) move.
	\end{enumerate}
\end{enumerate}

The restrictions do not affect the class $\npoly$ because if we are
given a machine which accepts $L$ in time $O(T)$,
there is another machine satisfying (1)--(3) which accepts
$L$ in time $O(T^2)$.

Since $M$ accepts $L$ in polynomial time, there is a polynomial $p(n)$
such that for any $w \in L$, Turing machine $M$ has an accepting
computation on input $w$ with at most $p(|w|)-1$ steps.  It
follows, therefore, that during the course of this computation, the
head of $M$ can scan at most the first $p(|w|)-1$ squares of its
tape.

We can view the computation of $M$ on input $w$ as a tableau, that is,
a matrix with $p(|w|)$ rows and $p(|w|)$ columns.  Each row of
the tableau represents the contents of the first $p(|w|)-1$
squares of $M$'s tape, and the state of $M$ is put immediately to the
left of the square under the tape head. Thus, for example, the starting
configuration is represented as $\#ws\#\#\cdots\#$.  Each row of the
tableau represents a configuration of $M$, and two consecutive rows
represent two consecutive configurations, with the exception that if
one row represents a halted configuration, this configuration is
repeated in all subsequent rows.

In order for a tableau to describe a valid accepting computation of
$M$ on input $w$, it must satisfy the following conditions:
\begin{enumerate}
\item  Row 1 represents the starting configuration $(s,\#w\underline{\#})$.
\item  Row $p(|w|)$ represents a halted configuration, which, by
restriction (2) on $M$, is equivalent to saying that the first square
of row $p(|w|)$ contains $h$.
\item 
For each $i$ in the range $1 \leq i \leq p(|w|)-1$, row $i+1$
represents a configuration which follows from the configuration
represented by row $i$ by executing a legal step of $M$; unless, of
course, the configuration in row $i$ is a halted configuration, in
which case rows $i$ and $i+1$ contain the same configuration.
\end{enumerate}
Thus $w\in L$ if and only if there is a tableau satisfying (1)--(3).


We now exhibit the function $f_L$ which reduces $L$ to $\GSAT$.  Given
$w$, we shall show how to compute (in time polynomial in $|w|$) a
Boolean formula $f_L(w)$ which is satisfiable if and only if there is
a tableau satisfying (1)--(3), that is, if and only if $w \in L$.

Let $\Gamma_t = \Gamma \cup K \cup \{h\}$, and $w = w_1\cdots w_n$,
where $w_i \in \Gamma$ for $1 \leq i \leq n$.  The Boolean formula
$f_L(w)$ has a variable $x_{i,j,\alpha}$ which is understood to be true
if and only if the square $(i,j)$ of the tableau contains the symbol
$\alpha$, where $\alpha \in \Gamma_t$ and $1
\leq i,j \leq p(n)$

The formula $f_L(w)$ is
structured so that there is a truth assignment satisfying $f_L(w)$ if and
only if the truth assignment describes a tableau satisfying (1)--(3).  The formula
$f_L(w)$ is the conjunction of four other formulae, $\phi_0 \land
\phi_1 \land \phi_2 \land \phi_3$, which we now define.
The formula $\phi_0$ has the property that a truth assignment satisfies
the formula if and only if the tableau corresponding to the truth
assignment has a unique symbol assigned to each square.  Namely, an
assignment satisfies $\phi_0$ if and only if exactly one of the
$x_{i,j,\alpha}$'s is true for each $(i,j)$.

$$\phi_0 = \bigwedge_{1
\leq i,j \leq p(n)} 
\left(
\left( \bigvee_{\sigma \in \Gamma_t} x_{i,j,\sigma} \right)
\land
\left( \bigwedge_{\sigma,\sigma' \in \Gamma_t \atop \sigma \not= \sigma'}
\lnot ( x_{i,j,\sigma} \land
x_{i,j,\sigma'}) \right) \right)\ .$$

The formula $\phi_1$ makes sure that the constraint (1) is met, that
is, the first row of the tableau is the starting configuration:
$$\phi_1 = x_{1,1,\#} \land x_{1,2,w_1} \land \cdots
\land x_{1,n+1,w_n} \land x_{1,n+2,s} \land x_{1,n+3,\#} \land \cdots
\land x_{1,p(n),\#}\ .$$

The formula $\phi_2$ makes sure that the constraint (2) is met, that is,
the last row of the tableau is a halted configuration:
$$\phi_2 = x_{p(n),1,h}\ .$$

The formula $\phi_3$ makes sure that the constraint (3) is met,
that is, one configu\-ra\-tion follows from the next by a legal move
of the Turing machine $M$.  In particular, row $i+1$ may only differ
from row $i$ locally.  
By restriction~4 (see page 3 of this Handout), in any move, $M$ changes
the current symbol  or moves the head (but does not do the two operation
at the same time).
Hence, as there are three possibilities for a legal
step of $M$ (write a symbol, move left, move right), there are three
ways that row $i+1$ can be different from row $i$.  Let $x,y \in \Gamma^*$,
and $\sigma, \sigma^\prime \in \Gamma$:


$$\matrix{
&\hbox{If } (q',\sigma') \in \delta(q,\sigma):
&\hbox{row {\it i}}
& \mbox{
\framebox[2cm]{\rule[-.1cm]{0cm}{.45cm} $\cdots x \cdots$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $q$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $\sigma$}\framebox[2cm]{\rule[-.1cm]{0cm}{.45cm} $\cdots y \cdots$}}\cr
  &\hbox{\ }
  &\hbox{row {\it i+1}}
  & \mbox{\rule[-.5cm]{0cm}{.5cm}
\framebox[2cm]{\rule[-.1cm]{0cm}{.45cm} $\cdots x \cdots$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $q'$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $\sigma'$}\framebox[2cm]{\rule[-.1cm]{0cm}{.45cm} $\cdots y \cdots$}} \cr
&\hbox{If } (q',L) \in \delta(q,\sigma):
&\hbox{row {\it i}}
&\mbox{
\framebox[2cm]{\rule[-.1cm]{0cm}{.45cm} $\cdots x \cdots$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $\sigma^\prime $}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $q$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $\sigma$}\framebox[2cm]{\rule[-.1cm]{0cm}{.45cm} $\cdots y \cdots$}}\cr
  &\hbox{\ }
  &\hbox{row {\it i+1}}
  &\mbox{\rule[-.7cm]{0cm}{.5cm}
\framebox[2cm]{\rule[-.1cm]{0cm}{.45cm} $\cdots x \cdots$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $q'$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $\sigma^\prime$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $\sigma$}\framebox[2cm]{\rule[-.1cm]{0cm}{.45cm} $\cdots y \cdots$}}\cr
&\hbox{If } (q',R) \in \delta(q,\sigma):
&\hbox{row {\it i}}
&\mbox{
\framebox[2cm]{\rule[-.1cm]{0cm}{.45cm} $\cdots x \cdots$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $q$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $\sigma$}\framebox[2cm]{\rule[-.1cm]{0cm}{.45cm} $\cdots y \cdots$}}\cr
  &\hbox{\ }
  &\hbox{row {\it i+1}}
  &\mbox{
\framebox[2cm]{\rule[-.1cm]{0cm}{.45cm} $\cdots x \cdots$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $\sigma$}\framebox[.8cm]{\rule[-.1cm]{0cm}{.45cm} $q'$}\framebox[2cm]{\rule[-.1cm]{0cm}{.45cm} $\cdots y \cdots$}}\cr}$$


The formula $\phi_3$ ensures that if square $(i+1,j)$ contains a
different symbol that square $(i,j)$, then this happened by executing a
legal step of $M$.  In order to propagate halting configurations until
the end of the tableau, we add to $\Delta$ the quadruple
$(h,\sigma,h,\sigma)$ for all $\sigma \in \Gamma$.  (The
Turing machine never uses this transition.  We throw it in for the purpose of
constructing the tableau.)  The formula $\phi_3$ is:  $$\phi_3 =
\bigwedge_{1\leq i,j \leq p(n) \atop \alpha \in \Gamma_t} 
\left( x_{i,j,\alpha} \land \lnot x_{i+1,j,\alpha}
\Rightarrow
\psi_{1,i,j} \lor \psi_{2,i,j} \lor \psi_{3,i,j} \right)\ ,$$
where $\psi_{1,i,j}$ describes writing a symbol, $\psi_{2,i,j}$ describes
moving left, and $\psi_{3,i,j}$ describes moving right.  In particular,

$$
\begin{array}{rcll}
\psi_{1,i,j}  &=& \bigvee_{(q',\sigma') \in \delta(q,\sigma)} &
 \parens{x_{i,j,q} \land x_{i,j+1,\sigma} \land x_{i+1,j,q'} \land x_{i+1,j+1,\sigma'}}\\
&&& \lor
 \parens{x_{i,j-1,q} \land x_{i,j,\sigma} \land x_{i+1,j-1,q'} \land x_{i+1,j,\sigma'}}
 \\
\psi_{2,i,j} &=& \bigvee_{(q',L) \in \delta(q,\sigma)  \atop \sigma' \in \Gamma}&
 \parens{x_{i,j,\sigma'} \land x_{i,j+1,q} \land x_{i,j+2,\sigma}
    \land  x_{i+1,j,q'} \land x_{i+1,j+1,\sigma'}
    \land x_{i+1,j+2,\sigma}}\\
&&& \lor
 \parens{x_{i,j-1,\sigma'} \land x_{i,j,q}
    \land x_{i,j+1,\sigma} \land
    x_{i+1,j-1,q'} \land x_{i+1,j,\sigma'}
    \land x_{i+1,j+1,\sigma}}
\\
\psi_{3,i,j} &=& \bigvee_{(q',R) \in \delta(q,\sigma)} &
 \parens{x_{i,j,q} \land x_{i,j+1,\sigma} \land x_{i+1,j,\sigma}
  \land x_{i+1,j+1,q'}}\\
&&& \lor
 \parens{x_{i,j-1,q} \land x_{i,j,\sigma} \land x_{i+1,j-1,\sigma}
\land x_{i+1,j,q'}}
\end{array}
$$

If $w\in L$, then a satisfying assignment for $f_L(w)$ can be read
off the tableau of an accepting computation of $M$ on $w$.
Conversely, if $f_L(w)$ is satisfiable, then any satisfying assignment
gives a tableau of an accepting computation of $M$ on $w$, which
implies $w \in L$.  Finally, one can verify that there is a polynomial
$p'$, which depends on $M$ and $p$, such that $f_L(w)$ can be
computed in $O(p'(|w|))$ steps.  This completes the proof of
Cook's Theorem.
\end{proof}



\section{Some $\npoly$-Complete Problems}

This section develops some classical $\npoly$-completeness results.

Thus far, we have proved only one language, GSAT, to be
$\npoly$-complete.  We shall find many more via reductions using the
following,

\begin{lemma} If $ A \leq_p B$ and $A$ is $\cal C$-hard, then
$B$ is $\cal C$-hard.
\end{lemma}

\begin{proof} By definition of $\cal C$-hard and transitivity
of $\leq_p$. 
\end{proof}

In particular, if GSAT $\leq_p B$ then $B$ is $\npoly$-hard.  It
often is not convenient to give reductions directly from GSAT,
however, because the formulas in it can be complicated.

We will show that the set of satisfiable formulas in conjunctive normal
form, a special case of GSAT, is also an $\npoly$-complete problem.
\begin{definition} A {\it literal\/} is either a Boolean
variable $x$ or its negation $\neg x$.  A {\it clause\/} is a Boolean
formula of the form $L_1 \vee \cdots \vee L_k$, where each $L_i$ is a
literal.  A Boolean formula is said to be in {\it conjunctive normal
form\/} (cnf) if it is of the form $C_1 \wedge \cdots \wedge C_k$,
where each $C_i$ is a clause.  A Boolean formula is said to be in {\it
3-conjunctive normal form\/} (3-CNF) if it is in conjunctive normal
form and each clause has exactly three pairwise unrelated literals.
Two literals are {\it related} if they are identical or 
one is the complement of the other.
\end{definition}

\noindent
{\bf Examples:}

\begin{enumerate}
\item $(x_1 \vee \neg x_2 \vee \neg x_3 \vee \neg x_4)
\land \lnot x_1 \land (\lnot x_2 \lor x_5)$ is in cnf.

\item $(\lnot x_1 \lor \lnot x_2 \lor \lnot x_3) \land (x_2 \lor
\lnot x_2 \lor x_3)$ is in 3-cnf.

\end{enumerate}

\begin{theorem} 3SAT $= \{\phi:\;\phi$ is a satisfiable
Boolean formula in 3-CNF$\}$ is $\npoly$-complete.
\end{theorem}


\begin{proof}Clearly 3SAT $\in \npoly$, so we need only prove GSAT $\leq_p$
3SAT. 

Certainly
any Boolean formula is {\it equivalent\/} to a cnf formula, but,
unfortunately converting an arbitrary formula to its equivalent cnf
does not yield a $\leq_p$-reduction (why?).  Fortunately, we don't
have to preserve equivalence, but only satisfiability.  Namely, we
show how, given any Boolean formula $\phi$, to construct in time
polynomial in the length of $\phi$ another formula, $\phi'$, in
3-cnf such that $\phi$ and $\phi'$ are equisatisfiable:

$$ \phi \in \hbox{ GSAT} \iff \phi' \in \hbox{ 3SAT} $$

The construction of $\phi'$ can be explained by considering an
example.  Say 

$$\phi \hbox { is } \lnot [((x_1 \Rightarrow x_2) \lor \lnot((\lnot x_1
\lor x_3) \lor x_4)) \land \lnot x_2].$$

Step 1. Introduce a new variable $y_i$ for each subformula of $\phi$
formed by a binary connective: 

$$\matrix{
 \neg[((x_1&\Rightarrow x_2)\quad&\vee\quad\neg((\neg x_1&\wedge x_3)
 \quad&\vee\quad x_4))\quad&\wedge\quad\neg x_2]\cr
 &y_1\hfill&y_2\hfill&y_3\hfill&y_4\hfill&y_5\hfill}$$

Step 2.  Form the conjunction, $\phi_1$, of formulas, each with at
most three variables, defining how the truth values of the subformulas
associated with the new variables are related:

$$
\begin{array}{rcl}
 \phi_1 & \hbox{ is } &(y_1 \equiv (x_1 \Rightarrow x_2)) \land \\
                     &&(y_2 \equiv (y_1 \lor \lnot y_4)) \land \\
                     &&(y_3 \equiv (\lnot x_1 \land x_3)) \land \\
		     &&(y_4 \equiv (y_3 \lor x_4)) \land \\
		     &&(y_5 \equiv (y_2 \land \lnot x_2)).
\end{array}$$

Now the whole formula $\phi$  is the negation of the subformula
associated with $y_5$; it follows that $\phi$ is satisfiable if and
only if $\phi_1 \land \lnot y_5$ is satisfiable (why?). So

Step 3. Form $\phi_2 := \phi \land \lnot y_5$.

Finally,

Step 4. Convert each of the at-most-three-variable conjuncts of
$\phi_2$ into {\it equivalent\/} cnf formulas.  Call the result 
$\phi_3$.

For example, the first conjunct of $\phi_2$, namely, $(y_1 \equiv (x_1
\Rightarrow x_2))$ is equivalent to $(\lnot x_1 \lor x_2 \lor \lnot
y_1) \land (y_1 \lor \lnot x_2) \land (y_1 \lor x_1)$, and the
second conjunct $(y_2 \equiv y_1 \lor \lnot y_4)$, is equivalent to
$(y_1 \lor y_2) \land (y_1 \lor \lnot y_2 \lnot y_4) \land (\lnot
y_1 \land \lnot y_2 \land \lnot y_4)$.

The final conjunct, $\lnot y_5$, is already an instance of a cnf
formula. So 

$$
\begin{array}{rcl}
 \phi_3 & \hbox{ is } &
    (\lnot x_1 \lor x_2 \lor \lnot y_1) \land (y_1 \lor \lnot x_2) \land (y_1 \lor x_1) \land \\
   &&(y_1 \lor y_2) \land (y_1 \lor \lnot y_2 \lor \lnot y_4) \land
     (\lnot y_1 \land \lnot y_2 \land \lnot y_4) \land \\
   &&(\ \ \ \ \ \ldots \ \ \ \ \ ) \land \\
   &&(\ \ \ \ \ \ldots \ \ \ \ \ ) \land \\
   &&(\ \ \ \ \ \ldots\ \ \ \ \ ) \land \\
   && \ \ \ \ \ \ \lnot y_5.
\end{array}
$$


Clearly, $\phi_3$ is equivalent to $\phi_2$ which is
equisatisfiable with $\phi$. 

Finally, we replace the clauses with fewer than three unrelated
literals with clauses containing exactly three unrelated literals per
clause. We first erase any clause containing a variable and its
negation and collapse identical literals into one, which yields an
equivalent formula with at most three literals per clause, 
all pairwise
unrelated.  We then replace two-literal clauses $(l_1 \lor l_2)$ by
$(l_1 \lor l_2 \lor x) \land (l_1 \lor l_2 \lor \lnot x)$, and
one-literal clauses $l$ by $(l \lor y_1 \lor y_2) \land (l \lor y_1
\lor \lnot y_2) \land (l \lor \lnot y_1 \lor y_2) \land (l \lor \lnot
y_1 \lor \lnot y_2)$, where the $x$'s and the $y$'s are new distinct
variables.  This produces the formula, $\phi^\prime$ with exactly
three distinct literals per clause, and $\phi^\prime$ is equivalent to
$\phi_3$.  We let the reader convince him/herself that the translation of
$\phi$ into $\phi'$ takes only polynomial time.  (Why was it OK to
convert the subformulas of $\phi_2$ into equivalent cnf formulas, but
not to convert the whole of $\phi$ directly into cnf?)  
\end{proof}


\begin{theorem} CLIQUE is $\npoly$-complete.
\end{theorem}

\begin{proof} We have already observed that CLIQUE
$\in\npoly$.  We shall prove it is $\npoly$-hard by showing
the known $\npoly$-hard problem 3SAT is $\leq_p$ CLIQUE.

Let $\phi$ be a Boolean formula in 3-cnf which has $m$ clauses.  We
construct a graph $G_\phi$ such that $\phi$ is satisfiable if and only
if $G_\phi$ has a clique of size $m$.

The graph $G_\phi=(V,E)$ is constructed as follows.  For each clause
$C_r = (l_i\lor l_j\lor l_k)$ in $\phi$ (the $l$'s are literals), there
is a triple of vertices $l^r_i$, $l^r_j$, and $l^r_k$ in $V$.  We put
an edge between two vertices $l^r_i$ and $l^s_j$ if: 
\begin{enumerate}
\item they are in different
triples ($r\neq s$), and 

\item they are consistent (one is not the negation of the other).
\end{enumerate}
For example, if

$$\phi = (x_1 \lor \lnot x_2 \lor \lnot x_3)
\land (\lnot x_1 \lor x_2 \lor x_3) \land (x_1 \lor x_2 \lor x_3)\ ,$$

\noindent then $G_\phi$ is the graph shown in Figure 1.  A satisfying
assignment of $\phi$ for this example is $x_1 = $ False, $x_2 = $
False, $x_3 = $ True.  A clique of size $m=3$ consists of $\lnot x_2$
from the first clause, $x_3$ from the second clause, and $x_3$ from
the third clause.

The graph $G_\phi$ can be computed in polynomial time given the formula
$\phi$.  We now claim the formula $\phi$ is satisfiable if and only if
$G_\phi$ has a clique of size $m$ (the number of clauses in the original
Boolean formula).  Suppose $\phi$ is satisfiable.  Then there is one
literal that must be True in each clause.  These literals form a clique
in $G_\phi$.  Suppose, on the other hand, that $G_\phi$ has a clique of
size $m$.  Then it must contain exactly one vertex per triple, and it
doesn't contain vertices which are inconsistent.  Therefore, the formula
$\phi$ is satisfied by assigning True to each literal in the clique.
\end{proof}


\begin{definition} A {\it hamiltonian circuit} of a graph $G$ is
a circuit which visits each vertex of $G$ exactly once.
$$\hbox{HAMC} = \{G: G \hbox{ is a graph which has a hamiltonian circuit}\}$$
\end{definition}

% \noindent For example, in Figure 4, the path $(1,3,2,4,5,1)$ is a hamiltonian
% circuit of $G_1$, but $G_2$ has no hamiltonian circuit.

There is no known polynomial-time algorithm for telling whether
a given graph $G$, has a hamiltonian circuit because of the next theorem.

\begin{theorem} 
HAMC is ${\npoly}$-complete.
\end{theorem}

\begin{proof} It is easy to see that HAMC $\in \npoly$.  We omit
a proof that it is $\npoly$-hard. 
\end{proof}

The traveling salesperson problem has been studied extensively.
The scenario for the problem is as follows.  A traveling salesperson
has $n$ cities that he wants to visit, and a matrix telling what it
costs to go from city $i$ to city $j$.  The salesperson would like
to visit all $n$ cities at minimum cost.  More formally, we have the
following problem.

TSP-TOUR : Given a complete graph $G$ (every pair of vertices is
connected by an edge) and a nonnegative integer cost associated with each
edge of $G$, find a hamiltonian circuit of $G$ with minimum cost.

% \noindent For example, in the instance shown in Figure 8, the optimal tour is
% $(a,d,b,c,a)$.  

An instance of TSP-tour can be presented as an $n \times n$
cost matrix $C$, where $n$ is the number of vertices of $G$.
The associated language recognition problem is the following.

$$
\begin{array}{ll}
\hbox{TSP} = \{(C,b) : &\hbox{ $C$ is a cost matrix, and $b$ is
a nonnegative integer such that $G$ } \\
&\hbox{ (the presumed underlying graph) has a hamiltonian circuit of
cost} \\
&\hbox{ at most $b$ }\}
\end{array}$$

Again TSP-tour is solvable in polynomial time if and only if TSP is in $\cal{P}$,
which is not likely:

\begin{theorem} TSP is $\npoly$-complete.
\end{theorem}

\begin{proof} Clearly, TSP is in $\npoly$.  To complete the proof,
we show that HAMC $\leq_{\cal{P}}$ TSP.

Let $G=(V,E)$ be a graph.  Consider a complete graph $G'$ with
vertex set $V$ (let $V = \{1,2,\cdots,n\}$), and the following cost
matrix:
$$c_{ij} = \left\{\vcenter{
\halign{$#$,\qquad & # \cr
1 & if $(i,j) \in E$,\cr
2 & otherwise.\cr}}\right.$$

The graph $G$ has a hamiltonian circuit if and only if $G'$
has a hamiltonian circuit with cost at most $n$.
\end{proof}

We have now seen enough examples of $\npoly$-complete problems to get
the point: they come up repeatedly in different areas.  Gary \&
Johnson's monograph, {\sl Computers and Intractability: A Guide to the Theory of
$\npoly$-
Completeness,}  W.H. Freeman and Co., San Fransisco, 1979, give hundreds 
of $\npoly$-complete problems.
The profound insight complexity theory offers is that these hundreds
of problems are all $\equiv_p$, and therefore from a computational
viewpoint can be seen as {\it the same problem}.  An operations
researcher who finds a polynomial time algorithm for TSP will
automatically provide a graph theorist with a polynomial time
algorithm for CLIQUE and will provide an electrical engineer a
polynomial algorithm for digital logic circuit minimization.
Conversely, a logician who proves that there is no polynomial time
algorithm
to test propositional formulas for satisfiability will eliminate
the possibility of finding polynomial time
algorithms for the $\npoly$-complete
problems in graph theory,  operations research, etc.

The fact that $\npoly$-complete problems have been studied in so many
disciplines by so many researchers without finding polynomial time
algorithms to decide them makes it seem unlikely that it will be easy to show
that ${\poly}= {\npoly}$.  In fact, most researchers believe ${\poly}
\not = {\npoly}$.  On the other hand, the known (diagonal)
methods for developing computationally complex problems are not capable of
showing that there is a problem in ${\npoly} - \poly$.

In practice, the prudent policy when working on an $\npoly$-complete
problem is like that for an undecidable problem: do {\it not} spend
time trying to find an algorithm which is always both correct and 
fast. If an algorithm is needed to solve an $\npoly$-complete problem,
efforts should be concentrated on alternative ways of attacking
the problem, say by trying to find heuristics that perform well in
practice or by trying to find efficient algorithms which are guaranteed
to produce near-optimal solutions.


\section{ Optimization versus Recognition}

Our study of complexity focused on recognition, but optimization
problems are more common.  For example, consider the following
computational problem:

\noindent MAXCLIQUE : given a graph $G$, find a clique of $G$ of maximum size.

MAXCLIQUE is typical of a large class of practical problems
(combinatorial optimization problems) where one is asked to determine
an element of some finite set which is optimal (either maximum or
minimum) under some cost criterion.  For example, in MAXCLIQUE the
finite set is the set of cliques of $G$, and the cost of a clique is
its size.  One can, in principle, solve a combinatorial optimization
problem by exhaustive search, but this approach is usually impractical
because of ``combinatorial explosion'' (there are just too many
elements to look at).  For example, trying to solve MAXCLIQUE by
enumerating all cliques of $G$ results in an exponential time
algorithm.  Is there an efficient (polynomial-time) algorithm for
MAXCLIQUE?

Let us reformulate the MAXCLIQUE problem as a {\it decision problem\/}
by adding a number to the input data.  The new problem is now, ``Given
a graph $G$ and an integer $k$, does $G$ have a clique of size $k$?''
Observe that this problem is now precisely the problem of deciding the
language CLIQUE.  Moreover, if MAXCLIQUE can be computed in polynomial
time, then CLIQUE can also be decided in polynomial time as follows.
Given $G$ and $k$, use the MAXCLIQUE algorithm to find a maximum
clique of $G$, and count up how many vertices are in it.  If the
number is at least as large as $k$, output {\bf Y}.  Otherwise,
output {\bf N}.

Interestingly enough, the converse is also true.  If  CLIQUE can be
decided in polynomial time, then MAXCLIQUE can be computed in polynomial
time. (It is left to you to see how this can be done.)  As a matter of fact,
analogous results can be proved for most combinatorial optimization
problems.  When this is the case, the question of existence of a
polynomial-time algorithm for the optimization problem can be replaced
by the question of existence of a polynomial-time algorithm for its
decision version.

\noindent {\bf Exercise: } Consider the problem SATISFY: ``given a
Boolean formula $\phi$, find a satisfying assignment for $\phi$ or
indicate that there is none.''  Show that there is a [[[polynomial time]]]
procedure for SATISFY if and only if ${\poly} = \npoly$. 


\end{document}

