\documentstyle[12pt,twoside,amssymb]{article}
\input{defs-6045}
%\input{defs-6045-1989}
\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}}

\begin{document}


\handout{recitation-hand33}{Recitation Notes about Handout 33}{April 22, 1992}

\bigskip

This handout reproduces  Section~8 of Handout 33, and is used 
in the recitation of week 11 of the course (from Monday, April 20 to Friday,
April 24).
\bigskip

\section{A useful operator on strings yielding regular expressions}
\label{sec:hat-operator}

We find it helpful to define an operator $\widehat{\hbox{\ }}$ that
can be applied to any {\it string}\/ $x\in\Sigma_c^*$ to yield a
{\it regular expression}\/, $\widehat{x}$, for which
$L(\widehat{x})=\{z\in\Sigma_c^*:\; x$ is {\it not}\/ a prefix of
$z\}$.  For example, $\widehat{abb}$ will be a (particular) regular
expression denoting the set of all strings in $\Sigma_c^*$ which do
{\it not}\/ begin with $abb$; any such string either has fewer than
three characters, or has at least three characters, but the first
three characters are not $abb$.  For the general case, we define
$\widehat{x}$ inductively, as follows:

\begin{enumerate}
\item $\widehat{\Lambda}=\emptyset$: $\Lambda$ is a prefix of {\it any}\/ string,
so $\emptyset$ is the set of strings that $\Lambda$ is not a prefix of, which is
itself a regular expression.

\item $\widehat{\sigma} = (\Sigma_c - \sigma) \Sigma_c^* \cup \{\Lambda\}$, 
for any $\sigma\in\Sigma_c$:
the set of strings not having $\sigma$ as a prefix is just the set
of all strings that start with some character other than $\sigma$,
together with the empty string.

\item $\widehat{\sigma x} = \widehat{\sigma} \cup \sigma\widehat{x}$,
for any $\sigma\in\Sigma_c$ and $x \neq \Lambda$:
the set of strings that do not begin with $\sigma x$ is the set of
strings that do not start with the character $\sigma$, together with
those that do start with $\sigma$, but whose remainder does not start with
$x$.
\end{enumerate}


Note that the right hand sides of the equations in (2) and (3)
above are not really regular expressions, 
but rather abbreviations for regular expressions.
For example, $\Sigma_c$
abbreviates $(\sigma_1\cup\sigma_2\cup
\cdots\cup\sigma_{|\Sigma_c|})$.  You should observe that the
length of the regular expression $\widehat{\sigma x}$ is
just some constant (depending on $M$) plus the the length of the
regular expression $\widehat{x}$.  Thus the length of the
regular expression $\widehat{x}$ is $O(|x|)$.  Furthermore, this
regular expression is readily computed from $x$ 
in polynomial time.


\section{NEREGSQ is not in $\poly$}


We have learned procedures for deciding whether a regular expression
denotes $\Sigma^*$.  That is, if we define
$$\hbox{NEREG} ::= \{E : \ E \hbox{ is a regular expression over alphabet
$\Sigma$ and } L(E) \not= \Sigma^*\},$$
then NEREG is a decidable language.

Let us introduce a formal
``squaring'' operation for regular expressions; namely, we will
say that if $E$ is a regular expression, 
then so is $(E)^2$ and 
$L\left((E)^2\right) \stackrel{\mbox{\tiny def}}{=}  L(E)\cdot L(E)$.
The languages expressible by regular expressions with squaring
are precisely the regular languages, for we can always take
a regular expression with squaring and write an equivalent
regular expression without squaring, using the fact that
$L\left((E)^2\right)=L(E\cdot E)$.
Thus, letting
$$\hbox{NEREGSQ} ::= \{E : E \hbox{ is a regular expression with squaring
over alphabet $\Sigma$ and } L(E) \not = \Sigma^* \},$$
we conclude that
$$\hbox{NEREGSQ} \equiv_m \hbox{NEREG},$$
and since NEREG is decidable so is NEREGSQ.

On the other hand, squaring can make significant difference in the {\it
length\/} of a regular expression.  For example, $$(\cdots((0 \cup 1
\underbrace{)^2)^2 \cdots)^2}_n$$
is a regular expression with squaring of length $O(n)$ denoting the set
$\{0,1\}^{2^n}$, but the size of the smallest regular expression
without squaring for this set is at least $2^n$.  So, as with the
example of UCOMPOSITE and COMPOSITE from section~2
of Handout~33
we would expect the distinction between NEREG and NEREGSQ to be
important in complexity theory.

In this section we will prove that NEREGSQ $\not\in {\poly}$.  (This
is not known to be the case for NEREG.)

NEREGSQ is our first example of a ``natural'' problem which is provably
infeasible. The only other problems we have seen which are provably
infeasible were constructed by diagonalization to have this property.
%Conceivably, all the ``real'' problems one might encounter could be in
%{$\poly$}, even though there exists problems which require more than
%polynomial time.  The result of this section proves that this is not the
%case.

We will actually prove a stronger fact:

\begin{theorem}  NEREGSQ is TIME$(2^n)$--hard.
\label{neregsq}
\end{theorem}


If NEREGSQ was in $\poly$,  Theorem~\ref{neregsq} would imply
that $\TIME(2^{n}) \subseteq \poly$. But 
we saw in class and in homework~9 that ${\poly}\psubset\TIME(2^{n})$.
So it certainly follows that NEREGSQ $\not\in \poly$.

\begin{proof} 
Let $L$ be any language such that $L\subseteq\Sigma^*$ and
$L\in\TIME(2^n)$.  For some $k$, the language $L$ will be decidable in
time $\leq 2^{kn}$ by a {\it one-tape, one-head\/} Turing machine, $M=
(K,\Sigma,\delta,s)$.

We can succinctly describe a configuration $(q,u,a,v)$ of $M$ as a
string, $uqav$.  We define the {\it computation words} for $M$ on
input $w$, to be certain strings over the alphabet $\Sigma_c = \Sigma
\cup \{\$\} \cup K \cup \{h\}$ 
(where $\Sigma, \{\$\} K,$ and $\{h\}$ are all assumed to be disjoint
sets).  Specifically, computation words for $M$ on input $w$, are of the
form

$$\$C_1\$C_2\$...\$C_l\$ $$

%[[[The letter n is already used for something else.]]]

\noindent where 
\begin{enumerate}
\item $C_1$ is of the form $\#ws(\#^j)$, where s is the start state and $j>0$, 
\item $C_i$ is of the form $u_iq_ia_iv_i(\#^{j_i})$ for all $i, 1 < i \leq l$,
where $u_i \in \Sigma^*$, $q_i \in K$, $a_i \in \Sigma$, $v_i \in \Sigma^+$ and
$j_i \geq 0$,
\item $(q_i, u_i, a_i, v_i) \vdash_M (q_{i+1}, u_{i+1}, a_{i+1}, v_{i+1})$ 
for each $i, 1 \leq i \leq l-1$, and
\item all the $C_i$'s have the same length, namely $|w| + j + 2$.
\end{enumerate}
The substrings of a computation word enclosed between \$'s 
are called {\it configuration words}.  
The configuration words do not include the \$ characters.

Note that $M$ accepts $w$ if and only if there is a
computation word for $M$ on $w$
such that $C_l$ is of the form $ \$hY\#^{j_l}\$ $.


We want to reduce $L$ to NEREGSQ.  To do this, we transform any string
$w \in \Sigma^*$ to an extended regular expression, $E_w$, such
that $L(E_w)=\Sigma_c^*-\{$the accepting computation word of $M$ on $w$
(if any) whose configuration words are of length exactly $n+3+2^{kn}\}$.
In particular, if there is no such computation word for $w$, then
$L(E_w)$ equals $\Sigma_c^*$.  Now suppose $w \in L$.  Then,
because of the assumed time bound for $M$, there is an accepting
computation word of the indicated form, so $E_w \in \hbox{NEREGSQ}$.  On
the other hand, if $w$ is not in $L$, then there is no such computation
word at all for $M$ on $w$, so that $E_w$ is not in NEREGSQ.  In
short, $$w\in L \hbox{ iff } E_w\in\hbox{ NEREGSQ}.$$  Finally, we will also show
that the construction of $E_w$ from $w$ can be done in time polynomial
(even linear) in $|w|$, so $L\leq_p$ NEREGSQ.

To understand how to construct $E_w$, first observe that whether a
string $z$ is a computation word for $M$ on input $w$ can be
checked using a
{\it legality}\/ function for $M$, 
$legal_M: {\Sigma_c} \times {\Sigma_c} \times {\Sigma_c} \times {\Sigma_c}
\rightarrow \Sigma_c$.  
We use this function to ensure that adjacent configuration words,
$C_i = a_1\cdots a_n$ and $C_{i+1} = b_1\cdots b_n$, are consistent
with the transition function of $M$.  In particular, we check the
local condition $b_{j+1} = legal_M(a_j,a_{j+1},a_{j+2},a_{j+3})$, for
all $j$.

\noindent More precisely, we define the computation words of $M$
in terms of the legality function for $M$ as follows.
We say that $z = z_1\cdots z_{|z|}$ is a computation word of $M$
exactly if it satisfies the following conditions.
\begin{enumerate}
\item the string $\$\#ws\#^i\$$ is a prefix of $z$ for some $i > 0$, and,
letting $m=|\$\#ws\#^i|$,

\item for all $j$, $|z| \geq j > m$,\ \ $z_j = {\it
legal}_M(z_{j-m},z_{j-m+1},z_{j-m+2},z_{j-m+3})$, and

\item $\$\#\;{\rm Y}\;h\#^{m-4}\$$ is a suffix of $z$.
\end{enumerate}


We are now going to use 
the   operator $\widehat{\hbox{\ }}$ defined in Section~\ref{sec:hat-operator}
 in order to reduce $L$ to NEREGSQ.  Recall that we
are assuming that $L$ is decidable by a 1-tape TM, $M$, in time
$2^{kn}$.  Thus $M$'s configuration words on $w$ need not have length
exceeding $2^{kn}+n+3$.  So $M$ accepts $w$, where $|w|=n$, iff $M$ has
an accepting computation word whose configuration words are of length
exactly $2^{kn}+n+3$.  And $M$ has such a computation word, $z$, iff
\begin{enumerate}
\item $z$ begins with $\$\#ws\#\#^{2^{kn}}\$$,

\item successive configuration words follow according to
the legality function for $M$, and

\item $z$ ends with $\$\#\;{\rm Y}\;h\#^{2^{kn}+n}$.
\end{enumerate}

Using our $\;\widehat{\hbox{\ }}\;$
operator, we can write a regular expression
with squaring that denotes the language over $\Sigma_c$ for which
these three conditions do {\it not}\/ hold:
\begin{enumerate}
\item $z$ does not begin correctly: either the initial four
characters are wrong, or there are the wrong number of \#'s to the right
of the head in the leftmost configuration word, 
or the initial configuration word in $z$ does not terminate with
a \$:
$$\widehat{\;\;\$\#ws\;\;} \cup\; (\$\#ws(\#\cup e)^{2^{kn}}\widehat{\#})
 \;\cup\; \$\#ws\#\#^{2^{kn}}\widehat{\$}.$$

\item some move is wrong: 
 $$\bigcup_{a,b,c,d\in\Sigma_c}\;\Sigma_c^*abcd\Sigma_c^{2^{kn}+n+1}
  \left(\Sigma_c-{\it legal}_M(a,b,c,d)\right)\Sigma_c^*.$$

\item $z$ doesn't end correctly.  This is handled analogously
to (1).
\end{enumerate}
The expression $E_w$ is the $\cup$ of the regular expressions with
squaring from (1), (2), and (3).  Again, the formulas exhibited above
are actually just descriptions of regular expressions with squaring:  we are
implicitly using the expressive power of the squaring operator
when we write things such as $\Sigma_c^{2^{kn}+n+1}$.  This would
correspond to a very long string without the squaring operator,
but by using the squaring operator repeatedly, this can
be written as 
$$(\cdots((\Sigma_c\underbrace{)^2)^2\cdots)^2}_{kn}\;
\underbrace{\Sigma_c\Sigma_c\cdots\Sigma_c}_{n+1},$$
which is of length $O(n)$.  The entire expression, $E_w$, is
of length $O(n)$.  

Now we have that any language $L\in\TIME(2^n)$ reduces to NEREGSQ
via a polynomial time reduction.
That is, $w\in L \Longleftrightarrow E_w\not=\Sigma_c^*$.  This means
that NEREGSQ is $\TIME(2^n)$--hard. 
\end{proof}


\end{document}
