\documentstyle[twoside,psfig]{article}
\input{defs-6045}
\newcommand{\mless}{\leq_m}
\newcommand{\meq}{\equiv_m}
\newtheorem{prop}[theorem]{Proposition}


\begin{document}

\handout{lecture20}{Notes on Lecture 20}{March 20, 1992}

\reading{Martin 20.2, 20.3, 20.4}

\section{Erratum}

There was a mistake in the notes for Lecture 19.  Theorem 2 should
read ``$L$ is {\it decidable} if and only if it can be enumerated
in increasing order'' (that is, in the canonical order of strings).


\section{Short Overview}

We've spent the last lecture or so looking at ways to prove that languages
are not T-acceptable and not recursive.  We will spend a few moments here
considering where this fits into the general picture of the course.

So far we've seen three different classes of machines, along with their
associated classes of languages:

\begin{center}
\begin{tabular}{l|l}
Machine & Language Class \\ \hline Finite Automata & Regular \\
Pushdown Automata & Context-free \\ Turing Machine & Recursive \\ 
& T-acceptable (or r.e.) \\ 
\end{tabular} 
\end{center} 

\noindent The classes of languages increased as the machines increased
in power.  Finally, with TMs, we have reached the limits of
computability; we believe that there are no more powerful models of
computation than TMs (e.g. whatever can be written in Pascal, C, or
Scheme can be implemented on a TM).

For every class of languages, we have been interested in how to prove
that languages are not in the designated class.  For example, with
regular languages, we were able to use the pumping lemma for regular
languages, or infinite sets of pairwise distinguishable strings to
prove that particular languages are not regular.  We were also able to
use the pumping lemma for context-free languages to prove that
particular languages are not context-free.  In the case of TMs, we
don't use structural arguments about the behavior of the machine to
make statements about what languages cannot be accepted by TMs.  We
were able to do that with regular and context-free languages because
the FA and PDA structure was simple enough to allow us to do so;
however, the structure of TMs can be quite complicated.  Instead, to
prove that a language cannot be accepted by a TM we have been using
higher-level arguments based on {\it diagonalization} and {\it
reducibility}.  

In contrast with the earlier parts of the course, we will be spending
most of this set of lectures showing that various languages are not
recursive.  With regular and context-free languages we spent only a
small part of the time showing that languages were non-regular or
non-context free.  However, since proving a language to be
non-recursive is equivalent to proving that it can't be decided by
any kind of computer at all, it is worth spending some time on these
notions in order to explore the limits of computation.

Once we are finished with this section of the course, we will
backtrack to the realm of computable functions and recursive languages
for the rest of the course.  We will consider once again more
restricted classes of languages, those that are restricted by their
{\it computational complexity.}

\section{More examples of undecidable problems}

\begin{example}
Consider the language $K_3 = \{ M : M$ halts on some input$\}$.
That is $K_3$ is the set of TMs such that $L(M) \neq \emptyset$.  We
claim that this problem is undecidable, and we will prove it by
showing that $K_0 \mless K_3$.  Recall that if $A \mless B$ and $A$ is
not recursive, then $B$ is also not recursive.  Recall also the
definition of reducibility:

\begin{definition}[Many-One-Reducibility]
\label{def:many-reducibility}
If $A\subseteq \Sigma_1^*$ and $B\subseteq \Sigma_2^*$ are two languages
we say that $A \mless B$ if there exists some total recursive function
$f: \Sigma_1^* \rightarrow \Sigma_2^*$ such that for all strings
$x \in \Sigma_1^*$, $x\in A$ iff $f(x)\in B$.
\end{definition}

To show that $K_0 \mless K_3$, we will use the function $f(<M,x>) =
M'_{M,x}$, where
$$ M'_{M,x} \left\{ \begin{array}{ll}
			\mbox{halts on all inputs} & \mbox{if $M$
halts on $x$} \\
			\mbox{does not halt for any input} & \mbox{if
$M$ does not halt on $x$}
		    \end{array}
	     \right.
$$
The function $f$, given $<M,x>$ as input, simply creates a new
encoding of the TM $M'_{M,x}$ which ignores its input, writes $x$ on
its input tape, then uses the transition function of $M$ to simulate
$M$ on $x$.

Now to show that $K_0 \mless K_3$, we must show that $f$ is a total
recursive function and that $<M,x> \in K_0$ iff $f(<M,x>) = M'_{M,x}
\in K_3$.  Since we can compute $f$ and $f$ is defined on all inputs
$<M,x>$, $f$ is total recursive.  If $<M,x> \in K_0$, then $M$ halts
on $x$.  So then $M'_{M,x}$ will halt on all its inputs, so certainly
it will halt on some input.  Thus $f(<M,x>) = M'_{M,x} \in K_3$.  If $<M,x>
\not\in K_0$, then $M$ will not halt on $x$, so $M'_{M,x}$ will not
halt on any input.  Thus $f(<M,x>) = M'_{M,x} \not\in K_3$.

Therefore, $K_0 \mless K_3$, and $K_3$ is not recursive.
\end{example}

\begin{example}
Consider the language $K_4 = \{ M : M$ halts everywhere$\}$.  We
can prove that $K_0 \mless K_4$ by using the very same function $f$
that we used in the previous example.  Hence $K_4$ is also
non-recursive.
\end{example}

\begin{example}
Consider the language $K_5 = \{<M_1,M_2> : L(M_1) = L(M_2), M_1$
and $M_2$ have the same input alphabet$\}$.  Recall that if we
constrain $M_1$ and $M_2$ to be DFAs, then $K_5$ is decidable: we have
an algorithm to check whether $L(M_1) = L(M_2)$ or not.  However, for
general TMs, $K_5$ is not decidable.  We will prove this by showing
that $K_4 \mless K_5$.  To see that this is true, consider the
function $g$, such that $g(M) = <M, M_T>$, where $M_T$ is a particular
TM which has the same input alphabet as $M$ and which accepts all its
inputs.  Certainly $g$ is a total recursive function.  If $M \in K_4$,
then $M$ accepts all its inputs, so that $L(M) = L(M_T)$.  So then
$g(M) = <M,M_T> \in K_5$.  Likewise, if $M \not\in K_4$, then $M$ does
not accept all its inputs, so that $L(M) \neq L(M_T)$, and $g(M) =
<M,M_T> \not\in K_5$.  Therefore, we have shown that $K_4 \mless K_5$.
\end{example}

\section{More Properties of $\mless$}

\begin{theorem}
If $A \mless B$, and $B$ is r.e.\  (that is, T-acceptable), then $A$ is
r.e.\   
\end{theorem}

\begin{proof}
Suppose that $A \mless B$ and $B$ is r.e.  Then there exists a TM $M$
that accepts $B$, and there exists a total recursive function $f$
such that $x \in A$ iff $f(x) \in B$.  We can construct a TM $M'$ to
accept $A$ as follows.  On input $x$, $M'$ will compute $f(x)$, then
will simulate the machine $M$ on $f(x)$.  If the simulation ever
halts, then $M'$ will halt.  Since $M$ will halt on everything in $B$,
and $f(x) \in B$ iff $x \in A$, then $M'$ will halt on everything in
$A$.
\end{proof}

\begin{corollary}
If $A \mless B$ and $A$ is not r.e.\ , then $B$ is not r.e.
\end{corollary}

Hence if $\overline{K}_0 \mless B$, then $B$ is not r.e.\ , since
$\overline{K}_0$ is not r.e.

Many-one reducibility also has the property that it is symmetric with
respect to the complement.

\begin{theorem}
$A \mless B$ if and only if $\overline{A} \mless \overline{B}$.
\end{theorem}

Here's one last property of $\mless$: if $A$ is r.e.\  but not
recursive, then $A$ and $\overline{A}$ are ``$\mless$-incomparable'';
that is, neither $A \mless \overline{A}$ nor $\overline{A} \mless A$.

\begin{theorem}
If $A$ is r.e.\  but not recursive, then $A$ and $\overline{A}$ are
$\mless$-incomparable.
\end{theorem}

\begin{proof}
Given the theorem above that says that $\mless$ is symmetric with
respect to the complement, if $A \mless \overline{A}$, then
$\overline{A} \mless A$.  The converse is true as well.  If either
statement holds, then $\overline{A} \mless A$.  But since $A$ is r.e.\ ,
it follows that $\overline{A}$ is r.e.\ , and thus that $A$ is recursive
(since both $A$ and $\overline{A}$ are r.e.\ ).  But $A$ is not
recursive, so we have reached a contradiction.  Hence it must be the
case that neither $A \mless \overline{A}$ nor $\overline{A} \mless A$.
\end{proof}

\section{Rice's Theorem}

Rice's theorem is a powerful result which can be used to show that
many languages are undecidable.  The theorem applies to sets of TMs,
and states that the set is undecidable if the languages accepted by
the TMs in the set are exactly those which satisfy a ``non-trivial''
property.

For simplicity's sake we will fix and alphabet $\Sigma$, and only
consider TMs that have alphabet $\Sigma$.  We now need to define what
we mean by a property of r.e.\  language being ``nontrivial''.  

\begin{definition}
A property of r.e.\  languages is {\it nontrivial} if and only if there
exists some r.e.\  language which satisfies the property and some r.e.\  language
which does not.
\end{definition}

For example, ``being r.e.\ '' is a trivial property of r.e.\  languages, since
every r.e.\  language is r.e.  ``Being non-empty'' is a non-trivial
property of r.e.\  languages, since the empty language is r.e.\  and
there are r.e.\  languages which are non-empty.

If $P$ is a property of r.e.\  languages, let $M_P = \{M : L(M)$ has
property $P\}$ (we assume all $M$ in $M_P$ have input alphabet
$\Sigma$).  Then $M_P$ is the set of all TMs that accept languages
satisfying $P$.

\begin{theorem}[Rice's Theorem]
If $P$ is nontrivial then $M_P$ is undecidable.
\end{theorem}

\begin{example}
Consider the set $\{M: M \mbox{ halts on } \Lambda\}$.  This set
corresponds to $M_P$ when $P$ is the property $\Lambda \in L(M)$.  $P$
holds for some r.e.\ languages, but not for others (e.g. for PAL, but
not for $1^+$).  Thus the set is undecidable by Rice's Theorem.
\end{example}

\begin{example}
Consider the set $\{M: M \mbox{ halts on all inputs}\}$.  This set
corresponds to $M_P$ when $P$ is the property $L(M) = \Sigma^*$.  $P$
holds for some r.e.\ languages, but not for others (e.g. for
$\Sigma^*$, but not for $\emptyset$).  Thus the set is undecidable by
Rice's Theorem.
\end{example}

\begin{example}
Consider the set $\{M: M \mbox{ halts on some input}\}$.  This set
corresponds to $M_P$ when $P$ is the property $L(M) \neq \emptyset$.
$P$ holds for some r.e.\ languages, but not for others.Thus the set is
undecidable by Rice's Theorem.
\end{example}

\begin{example}
Consider the set $\{M: M \mbox{ accepts a regular set} \}$.  This set
corresponds to $M_P$ when $P$ is the property ``$L(M)$ is regular''.
Thus the set is undecidable by Rice's Theorem.
\end{example}

\begin{example}
Consider the set $\{M: M \mbox{ halts exactly for even length
inputs}\}$.  This set corresponds to $M_P$ when $P$ is the property
``$L$ is the set of strings of even length''. Thus the set is
undecidable by Rice's Theorem.
\end{example}

\section{Proof of Rice's Theorem}

To prove Rice's theorem, we split the proof into two cases:
\begin{enumerate}
\item $\emptyset$ does not satisfy $P$.  Then we show $K_0 \mless
M_P$.
\item $\emptyset$ does satisfy $P$.  Then we show $K_0 \mless
\overline{M}_P$.
\end{enumerate}
\noindent In either case, $M_P$ will be undecidable by the properties
of $\mless$.

\subsection{Case 1}

Assume that $\emptyset$ does not
satisfy $P$.  Then let $M_1$ be a particular TM with input alphabet
$\Sigma$ such that $L(M_1)$ satisfies $P$.  We know that $L(M_1)$ (and
hence $M_1$) must exist by the nontriviality of $P$.  We also know
that $L(M_1) \neq \emptyset$, since $\emptyset$ does not satisfy $P$.

We want to show that $K_0 \mless M_P$.  We will consider a restricted
version of $K_0$ that has only machines with input alphabet $\Sigma$;
one can show that this version is still undecidable.  Define $f(<M,x>)
= N_{M,x}$, where $N_{M,x}$ behaves as follows: ``Given input $w$,
$N_{M,x}$ first simulates $M$ on $x$.  If the simulation halts, then
it simulates $M_1$ on $w$.''  Certainly $f$ is total recursive (we
could build a TM to convert $<M,x>$ into an encoding of $N_{M,x}$).
We now need to show that $<M,x> \in K_0$ iff $f(<M,x>) = N_{M,x} \in
M_P$.  Suppose $<M,x> \in K_0$.  Then $M$ halts on input $x$.  So then
on input $w$, $N_{M,x}$ will halt iff $M_1$ halts on $w$.  Therefore,
$L(N_{M,x}) = L(M_1)$.  Since $L(M_1)$ satisfies $P$, $N_{M,x} \in
M_P$.  Now suppose that $<M,x> \not\in K_0$.  Then $M$ does not halt
on input $x$. Thus $N_{M,x}$ does not halt for any input $w$.  Thus
$L(N_{M,x}) = \emptyset$, and $L(N_{M,x})$ does not satisfy $P$ (since
$\emptyset$ doesn't satisfy $P$).  So $N_{M,x} \not\in M_P$.
Therefore, we have shown that in Case 1, $K_0 \mless M_P$.

\subsection{Case 2}

Assume $\emptyset$ satisfies $P$.  Then let $Q = \overline{P}$, the
property of {\it not} satisfying $P$.  Then $M_Q = \overline{M}_P$.
Now $\emptyset$ doesn't satisfy $Q$.  By Case 1, $K_0 \mless M_Q$.  So
then $K_0 \mless \overline{M}_P$.

\vspace{.2in}

We will see in the next lecture some more examples of how we can apply
Rice's theorem.  We will also see some examples of where it does not
apply.


\end{document}
