
\documentclass{article}

\usepackage{xspace,graphicx,hyperref,paralist}

\newtheorem{illustration}{Illustration}[section]
\newtheorem{theorem}{Theorem}[section]


\newcounter{exer}
\renewcommand{\theexer}{\thechapter:\arabic{exer}}

\newcommand{\FIXIT}[1]{\typeout #1 -- {\LARGE\sf #1}}

%---
\newcommand{\TM}{{Turing machine}\xspace}
\newcommand{\TMs}{{Turing machines}\xspace}
\newcommand{\NPCness}{{NP-completeness}\xspace}
\newcommand{\NPC}{{NP-complete}\xspace}
\newcommand{\NPH}{{NP-hard}\xspace}
\newcommand{\sfP}{{\sf P}\xspace}
\newcommand{\sfNP}{{\sf NP}\xspace}
\newcommand{\sfNPC}{{\sf NPC}\xspace}
\newcommand{\sfNPH}{{\sf NPH}\xspace}
\newcommand{\sfCoNP}{{\sf CoNP}\xspace}
\newcommand{\sfCoNPC}{{\sf CoNPC}\xspace}
\newcommand{\BA}{{B\"{u}chi automata}\xspace}
\newcommand{\BAon}{{B\"{u}chi automaton}\xspace}
\newcommand{\TL}{{Temporal Logic}\xspace}
\newcommand{\LTL}{{linear-time temporal logic}\xspace}
\newcommand{\CTL}{{Computational Tree Logic}\xspace}
\newcommand{\KS}{{Kripke structure}\xspace}
\newcommand{\KSs}{{Kripke structures}\xspace}
\newcommand{\OR}{{$\omega$-regular}\xspace}
%---


\oddsidemargin 0cm
\textwidth 17cm

\begin{document}
{\hfill \large\bf CS 3100 -- Models of Computation -- Fall 2011 --  Notes for L26 \hfill}

{\hfill \large\bf Computability, Undecidability \hfill}

{\hfill \large\bf Last Updated 10:01am, 11/29/11 \hfill }

\subsubsection*{Cardinalities (recap)}

\begin{compactitem}
\item We can show that the cardinality of the set of finite fractions between
  0 and 1 is $\aleph_0$ (try using the S-B theorem)
\item Write another proof for the cardinality of the set of all C programs,
  using the S-B theorem.
\item We also solved for the cardinality of the set of all languages
  over $\Sigma^*$ where $\Sigma$ is some non-empty alphabet (singleton alphabet
  is OK). Recap that.
\item Mismatches of cardinality were argued using the {\em diagonalization} method.
  Make sure you understand that.
\end{compactitem}

\subsubsection*{Remaining Portions: the Halting Problem; Mapping Reductions; BDDs}

\begin{compactitem}
\item We will resort to the diagonalization argument in showing the undecidability
  of the halting problem
\item We have to build up our notions before we can do that
\item We will show how to relate problems to each other using mapping reductions
  (so using the unsolvability of one problem, we can show the unsolvability of other
  problems).
\item These arguments are also used for showing NP-completeness
\item To appreciate NP-completeness and the power of Boolean reasoning, we will revisit
  DFA; we can show how they can compactly encode Boolean functions (in the form of ``BDDs'')
\end{compactitem}


\subsubsection*{Languages of Machines}

\begin{compactitem}
\item So far we studied languages that have a ``real purpose'' -- e.g. language of all
  strings with an odd number of 1's
\item We also studied languages that legally encode machines -- e.g. ``is this a regular
  expression'' or ``is this a CFG'' or ``is this a PDA description in some encoding format''
  or ``is this a DFA encoding as per JFLAP's conventions''

\item We will simply write 

 \[ \{\langle D\rangle \;\mid\; D\;is\;a\;DFA\} \]

to denote ``the language of legal DFA encodings.''

\item Now we can ask more interesting questions:
  \begin{compactitem}
  \item Is this a DFA we are looking at, and {\em furthermore}, 
    is it those DFAs that do not accept strings with odd 1s.

\[ \{ \langle A \rangle \;\mid\; A\; {\rm is\; a\; DFA\; that\; does\;
   not\; accept\;any\;string\;with\;odd\;1s }\}. \]

or

\[ \{ \langle D \rangle \;\mid\; D\; {\rm is\; a\; DFA\; that\; does\;
   not\; accept\;any\;string\;with\;odd\;1s }\}. \]

(the letter we use does not matter; it is a variable)

  \end{compactitem}

\item When we say ``we,'' we don't mean humans. Eventually we want to automate things.
  So we (humans!) will say ``is a TM looking at DFAs, claiming to filter out exactly
  those that do not accept strings with odd 1s?''

\item An algorithm has an input, generates an output, is effective (mechanizable),
  definite (not non-deterministic), and finite (halts). We are mainly focussed
  on {\em finiteness} in these discussions (we assume the rest of all problems discussed
  here).

\item We (humans -- clear from the context, now on, I hope) want TMs to be {\em algorithmic}
  TMs. I.e. when fired up, the TM must do the job and halt in an accepting state saying
  ``yes, found such a DFA'' or ``no, this ain't such a DFA.'' Then only it can
  separate $\Sigma^*$ into two bins: (1)~those strings from $\Sigma^*$ that
  encode DFAs that do not accept odd 1s, and (2)~those strings that either don't
  encode DFAs or encode DFAs that have at least one odd-length string in its language.

\item But we will find that life isn't so smooth; some problems do have algorithms; 
  some problems don't have algorithms; and some have {\em semi-algorithms}!

\item The most important modeling trick:
  \begin{quote}
  Problem solving = Language decision! 
  \end{quote}
 That is, to solve a problem, model the problem using a language, and then try and
 build a TM that decides membership in the language.

\item Building a TM is {\bf really not necessary}; instead, just imagine
  writing a C or Java program (or Python, or ..)


\item Examples:
  \begin{itemize}
  \item Problem with an algorithm (language that is decidable):
    \[ \{ \langle M\rangle \;\mid\; M\;is\;a\;TM\} \]
    Clearly, one can check that a legal TM has been encoded as per
    some syntactic conventions.

    Another example:
    \[ \{ \langle M,w\rangle \;\mid\; M\;is\;a\;TM\; and\; w\; is\; a\; string\; 
  in\; the\; tape\; alphabet\; of\; M\} \]
  Even this is algorithmically checkable. One agrees on a convention to ``lay down''
  a TM description of $M$ on a tape, then put a separator, then put down $w$.

  \item Problem with a semi-algorithm:
    \[ A_{TM} = \{ \langle M,w\rangle \;\mid\; M\;is\;a\;TM\; and\; w\; is\; a\; string\; 
  in\; the\; tape\; alphabet\; of\; M\;and\;M\;accepts\;w\} \]
  This has a semi-algorithm. Simply let a ``master'' TM (who is doing the language
  filtering) run $M$'s steps on $w$ (work like an $M$-interpreter.
  If and when $M$ is found to accept $w$, declare ``$\langle M,w\rangle$''
  is in $A_{TM}$.

 \item Problems with  {\em not even a semi-algorithm}:
    \[ EQ_{TM} = \{ \langle M_1,M_2\rangle \;\mid\; M_1\;and\;M_2\;are\;language\;
    equivalent\;TMs \} \]
    Can't conclusively prove halting, in an identical manner,
    of $M_1$ and $M_2$ over all of $\Sigma^*$.


 \item Problems with  {\em not even a semi-algorithm}:
    \[ NEQ_{TM} = \{ \langle M_1,M_2\rangle \;\mid\; M_1\;and\;M_2\;are\;language\;
    non-equivalent\;TMs \} \]
    Can't conclusively prove halting, in a non-identical manner (if $M_1$ accepts,
    $M_2$ does not accept),
    of $M_1$ and $M_2$ over all of $\Sigma^*$.
    
  \end{itemize}

\item Note that TMs $M$ run on $w$ have three outcomes, {\bf only two of which are
    discernible}:
  \begin{compactitem}
  \item Accept
  \item Reject
  \item Loop (is an outcome, but we don't know we can't tell that we are doing that!!!)
  \end{compactitem}

\item Warning: Don't simply run a given $M$ on a string $w$. There may
  be better algorithms around. The {\em existence of algorithms} or
  {\em existence of semi-algorithms}
  can often be 
  concluded smartly. Look for cut-offs or other ways to ``dovetail and run other
  computations in parallel.''

  Examples:
  \begin{compactitem}
  \item Wrong semi-algorithm: Generate one string $w_1$ from $\Sigma^*$. Deploy
    $M$ on $w_1$. If and when $M$ is found to reject $w_1$, 
    move on to another string $w_2$, etc. {\em What is wrong?}\footnote{$M$ may loop on $w_1$.
      Looping is not detectable. Looping may be an ever increasing exaggerated
      zig-zag over TM's tape, with nothing repeating! While we are at it, we {\bf can}
    detect that a PDA is looping, as well as an LBA is looping - how? Unfortunately,
  looping in TMs is not detectable. This is our main theorem about the ``Halting problem.''}
  \item
    \[ NE_{TM} = \{ \langle M\rangle \;\mid\; M\;is\;a\;TM\; with\;a\;non-empty\;language\}\]
    A semi-algorithm exists. One can keep cranking out strings ``along the x axis''
    and run $M$ on each string so far generated ``along the $t$ (or time) axis''
    for some fixed number of steps (usually 1) before generating another string.
    So we generate one string, run one more step of $M$ over all strings, then
    generate one more string, etc. If $L(M)$ is non-empty, we will eventually
    hit upon some string $w_a$ and have allocated the right number of steps
    of $M$'s run on $w_a$ to have sent $M$ to its accept state.
    
  \end{compactitem}

\item Note that if we have
a semi-algorithm for a problem and its complement (language and its complement), then 
we will have a {\em full} algorithm.

    \[ NE_{TM} = \{ \langle M\rangle \;\mid\; M\;is\;a\;TM\; with\;a\;non-empty\;language\}\]


\item Questions on the decidability of  $NOODD_{DFA}$ and $A_{CFG}$: find
  an {\em algorithm} to describe the membership (or not) of a candidate string
  in these languages in a {\em finite} manner -- {\em i.e.} finish the work
  and halt with a ``yes/no.'' All algorithms in our discussion are described
  using pseudo-code and/or precise English bulletted steps.

\item An enumerator for $NEQ_{CFG}$ guarantees to list each unequal grammar pair
  in a finite amount of time. Think of the difficulty you are
  faced with (over 15 mins or so of deep thought about the matter)
  as to why $EQ_{CFG}$ -- language-equivalent grammar pairs -- can't be
  enumerated.

\item The existence of a semi-algorithm means ``one has proved, or nobody knows
  whether there is a full algorithm.'' As usual, we use the tighest classification,
  never calling $1$ a complex number or $\{\}$ a context-free language.

\item The words
  decidable and undecidable are opposites; undecidable means {\em not decidable}.

\item The word semi-decidable means undecidable, but {\em partially decidable} ({\em i.e.}
  solvable in the true sense, but not the false sense, or vice versa; one has to clarify
  which sense holds). $EQ_{CFG}$ is not decidable but semi-decidable: this is because
  one can guarantee halting at least when the CFGs are language {\em inequivalent}.
  For this to happen, they must disagree on at least one string.

\item Problem: {\bf \( ALL_{DFA} \):\/} Given a DFA, is its language $\Sigma^*$? 
  Is this problem / language decidable?

\item How about {\bf \( A\varepsilon_{CFG}  \):\/} Given a CFG, does it generate $\varepsilon$?

\item How about  \( INFINITE_{DFA} \): Given a DFA, does it have an infinite language?

\item How about 
\[  EMPTY_{CFG} = \{ \langle G\rangle \;\mid\; {\rm is\; a\; CFG\; and\; L(G)=\emptyset} \}. \]

\begin{list}{$\bullet$}{\addtolength{\itemsep}{-1.6\itemsep}}
\item The universality of the language of a CFG is undecidable. 
   A language $L$ is universal \index{Language!universality}
   if $L=\Sigma^*$.
\item The equivalence of two CFGs is undecidable.
\item In-equivalence of two CFGs is undecidable.
\item Whether a given Turing machine accepts string $w$ is undecidable.
\item Whether a given Turing machine halts on string $w$ is undecidable.
\item The emptiness of the language of a \TM is undecidable.
\item Whether a given \TM's language is context-free is undecidable.
\end{list}

A language $L$ is TR if it is the language of {\em some} Turing machine $M$.
We write $L_M$ for emphasis.
%
A language $L$ is RE if there exists a Turing machine $M$
that can enumerate the strings in $L$ (say, on an ``output tape'') such that any
member $x\in L$ is guaranteed to appear in a finite amount of time.
%

\noindent Some clarifications:
\begin{compactitem}
\item Suppose we are required to show that $L$ is TR.
  We must seek a Turing machine that
  \begin{compactitem}
  \item Accepts a candidate string $x$ in $\Sigma^*$
  \item Engages in the process of determining whether $x\in L$
  \item Halts in the ``Accept'' state if $x\in L$
  \item Is not required to behave in any specific way (may halt
    in a non-accepting state---{\em or in other words, reject $x$}---if
    $x\notin L$. Or it may loop forever.
  \end{compactitem}

\item Suppose we are required to show that $L$ is RE.
  We must seek a Turing machine that
  \begin{compactitem}
  \item After being fired up, may never stop
  \item The TM is expected to print out on the tape each member of $L$
    in a finite amount of time, typically one string after the other.
  \end{compactitem}
\end{compactitem}


\noindent For instance,
\( NEQ_{CFG} = \{ \langle G_1,G_2 \rangle \;\mid\; G_1,G_2\; {\rm are\; \; CFGs\; and\;} L(G_1) \neq L(G_2) \} \)
is TR.

\noindent{\bf Many TMs may be ``up to the job'':\/}
Notice that if $L$ is $L_M$ for one TM $M$, then it is the language of an infinite number ($\aleph_0$)
of other machines, $M^{'}$, as we can simply pad $M$ with $i$ ``no op'' instructions, for every $i\in Nat$.
%
Each such artificially bloated TM is indeed considered a distinct TM!

A recursively enumerable (RE) language is the language that an {\em enumerator} \TM
can enumerate.
%
An enumerator \TM is a \TM that has no input tape, but has an output tape.
%
In addition, it may employ a working tape.
%
It keeps generating (finite) strings, and appends each generated string to
the output tape.
%
$NEQ_{CFG}$ is RE.

{\bf A language is TR if and only if it is RE.}
%
 The main argument is that given an enumerator (in the sense of RE), we can
build a recognizer (in the sense of TR), and vice versa.
%
The main reason one should study both these definitions is to gain
mathematical maturity as well as gain experience building various types
of TMs. 
%
It also improves one's ability to come up with innovative proofs either
using the TR type of TMs or the RE types of TMs.

A recursive language $L_M$ is the language of a Turing machine $M$
that, given any $x\in L_M$, accepts $x$, and given any $y\notin L_M$, rejects $y$.
%
In other words, $M$ does not loop on any input.
%
Note that it is possible to have another machine $N$ such that $L(M)=L(N)$
and $N$ loops on inputs $y\notin L_M$;  however, so long as there exists
{\em one} decider $M$, we can conclude that $L_M$ is recursive (or
decidable).

\noindent Another {\em very important} characterization of recursive languages is this:
%----------------------
$L$ is recursive if and only if $L$ and $\overline{L}$ are RE (equivalently, are TR).


The cardinality of the set of all \TM descriptions is $\aleph_0$.
%
This is because a \TM can be described through a finite number of
bits that model its states and its transitions, and such a description
can be read as a natural number (these numbers are known as G\"{o}del
numbers).
%
On the other hand, there are $\aleph_1$ languages over $\Sigma$.
%
Therefore, there are non-TR (non-RE) languages.
This means that there exist languages in which membership testing cannot be
carried out by {\em any} Turing machine.
$EQ_{TM}$ is neither RE nor co-RE (both itself and its complement are non-RE).

\end{compactitem}
\end{document}

\subsection{Acceptance ($A_{TM}$) is undecidable (important!)}
\label{sec:contrad}
\index{$A_{TM}$}
%
This is one of the most fundamental results that we shall encounter in
our study of \TMs and computation.
%
Define
\[ A_{TM} = \{ \langle M,w\rangle \;\mid\; M\; {\rm is\; a\; Turing \; machine \; that\; accepts\; string} \;w \}. \]
%
Deciding membership in $A_{TM}$ is tantamount to asking ``does a given
\TM $M$ accept a string $w$?''
%
We prove this set to be {\em undecidable} through contradiction, as follows:

\begin{list}{$\bullet$}{\addtolength{\itemsep}{-1.6\itemsep}}
\item {\bf Suppose} there exists a decider $H$ for $A_{TM}$. $H$ expects to be
 given a \TM $M$ and a string $w$. Notice that ``giving $H$ a \TM'' means
 ``giving it a character string representing a \TM program.''
 Hence, in reality, we will be feeding it $\langle M,w\rangle$ as mentioned in
 Section~\ref{sec:decidable-list}.
\item Build a program called $D$ as follows:
  \begin{list}{$-$}{\addtolength{\itemsep}{-1.6\itemsep}}
  \item $D$ takes a single argument $M$.
  \item As its first step, $D$ invokes $H$ on $\langle M,M\rangle$.\footnote{Basically,
   we feed $\langle M\rangle$ twice over, just to `please' $H$ that expects two arguments.}
  \item If $H(\langle M,M\rangle)$ rejects, $D(\langle M\rangle)$ accepts.
  \item If $H(\langle M,M\rangle)$ accepts, $D(\langle M\rangle)$ rejects.
  \end{list}
% \footnotetext{Basically, we feed $\langle M\rangle$ twice over, just to `please' $H$ that expects two arguments.}
%
\item Now we can ask what $D(\langle D\rangle)$ will result in (to preserve the clarity of our arguments,
the reader is invited to suppress any occurrence of $\langle\ldots\rangle$ in the text below):
%
\begin{list}{$-$}{\addtolength{\itemsep}{-1.6\itemsep}}
\item The $D(\langle D\rangle)$ ``call'' turns into an $H(\langle D,D\rangle)$ call.
\item[]
\item Suppose $H(\langle D,D\rangle)$ rejects. In that case, \fbox{$D(\langle D\rangle)$ accepts.}
\item But, according to the advertised behavior of $H$ --- which is that it is a decider for $A_{TM}$ --- the
fact that $H(\langle D,D\rangle)$
 rejects means that $D$ is {\em not} a Turing machine that will accept $\langle D\rangle$, or
that \\
\fbox{$D(\langle D\rangle)$ rejects!}
\item[]
\item Suppose $H(\langle D,D\rangle)$ accepts. In that case, \fbox{$D(\langle D\rangle)$ rejects.}
\item But, according to the advertised behavior of $H$ --- which is that it is a decider for $A_{TM}$ --- the
fact that $H(\langle D,D\rangle)$
 accepts means that $D$ {\em is} a Turing machine that accepts $\langle D\rangle$, or
that \\
\fbox{$D(\langle D\rangle)$ accepts!}
\end{list}
\end{list}
%
\noindent Therefore, we obtain a contradiction {\em in both cases}.

%\footnotetext{Please recall our discussions of Section~\ref{sec:russells-paradox}.}
%
Hence, the claimed decider $H$ for $A_{TM}$ cannot exist, or
%
\begin{quote}
The {\em acceptance problem} for Turing machines is undecidable. 
\end{quote}
\index{Acceptance problem}

\subsection{Halting ($Halt_{TM}$) is undecidable (important!)}
%
\label{sec:reduction}
\index{$Halt_{TM}$}
%
\begin{figure}[tbhp]
  \begin{center}
  \includegraphics[scale=0.4]{atm_to_halt_reduction.pdf}
  \end{center}
  \caption{$A_{TM}$ to $Halt_{TM}$ reduction.
  Notice that {\em if} we assume that the inner components --
   namely the OR-gate, the ability to run $M$ on $w$, and $D_{Halt_{TM}}$ exist, then
   $D_{ATM}$ can be constructed; and hence, $D_{Halt_{TM}}$ cannot exist!}
  \label{fig:atm_to_halt_reduction}
\end{figure}


\begin{quote}
The golden rule of reduction is:
{\bf Reduce an existing (``old'') undecidable problem to the given (``new'') problem.}
This way, if we assume that the new problem is decidable, we would be
forced to conclude that the existing undecidable problem is decidable --- a
contradiction. See Figure~\ref{fig:atm_to_halt_reduction} where the
``{\em new problem}'' is $Halt_{TM}$, and by assuming that it is decidable, we can
assume the existence of the decider $D_{Halt_{TM}}$, and using it, build a
decider for $A_{TM}$, the ``{\em old problem}'' already shown to be undecidable;
this obtains a contradiction. Hence, $D_{Halt_{TM}}$ cannot exist.
\end{quote}

\subsubsection{Don't get reduction backwards!}

We should not go by the English language meaning
 of the term ``reduction'' that can lead us astray.
 %
Getting the meaning of `reduction'
 backwards means trying to reduce the new problem
 to an existing (``old'') problem.
%
This does not help us.
%
To see why, assume this to be the right direction.
%
Then we will be trying to employ proof by contradiction (following
reduction) in the following
futile way: ``IF the existing undecidable problem is decidable, THEN
we would have shown the new problem to be decidable.'' However,
this is a statement of the form ``IF false, THEN assert X.''
Clearly, in this case, we cannot assert X.

\subsubsection{An introduction to mapping reduction}

{\em Reduction} is an abbreviation for {\em mapping reduction} --- a concept
fully explored in Section~\ref{sec:mapping-red}.
%
In this section, we informally apply
the (mapping) reduction idea to show that $Halt_{TM}$ is undecidable.
%
Define
\[ Halt_{TM} = \{ \langle M,w\rangle \;\mid\; M\; {\rm is\; a\; Turing \;machine\; that\; halts\;on\; string} \;w \}. \]
%
We show $Halt_{TM}$ to be undecidable as follows:
%
\begin{quote}
  Suppose not; i.e., there is a
  decider for $Halt_{TM}$. Let's now build a decider for
    $A_{TM}$ (call it $D_{A_{TM}}$).
  $D_{A_{TM}}$'s design will be as follows:
    %--
    \begin{list}{$-$}{\addtolength{\itemsep}{-1.7\itemsep}}
    \item $D_{A_{TM}}$ will first feed $M$ and $w$ to
      $D_{Halt_{TM}}$, the claimed decider for $Halt_{TM}$.
    \item If $D_{Halt_{TM}}$ goes to $accept_{\textstyle D_{Halt_{TM}}}$, 
      $D_{A_{TM}}$ knows that it can safely run $M$ on $w$, which it does.
    \item If $M$ goes to $accept_{\textstyle M}$, $D_{A_{TM}}$ will go to $accept_{\textstyle D_{A_{TM}}}$.
    \item If $M$ goes to $reject_{\textstyle M}$, or if
      $D_{Halt_{TM}}$ goes to $reject_{\textstyle D_{Halt_{TM}}}$,
      $D_{A_{TM}}$ will go to $reject_{\textstyle D_{A_{TM}}}$.
    \end{list}
\end{quote}
%
Notice that we have labeled the accept and reject states of
the two machines $D_{Halt_{TM}}$ and $D_{A_{TM}}$.
%
After one becomes familiar with these kinds of proofs,
higher-level proof sketches are preferred.
%
Here is such a higher-level proof sketch:
%
\begin{quote}
Build a decider for $A_{TM}$. This
decider accepts input $\langle M,w\rangle$ 
and runs $Halt\_decider$ (if it exists) on it. If this run accepts,
then we can safely (without the fear of looping) run $M$ on $w$,
and return the accept/reject result that this run returns;
else return ``reject.''
\end{quote}
A diagram that illustrates this construction is in
Figure~\ref{fig:atm_to_halt_reduction}.
%
Therefore, we conclude that
%
\begin{quote}
the {\em Halting problem} for Turing machines is undecidable. 
\end{quote}
\index{Halting problem}

Two observations that the reader can make after seeing many such proofs
(to follow) are the following:
%
\begin{list}{$\bullet$}{\addtolength{\itemsep}{-1.6\itemsep}}
\item  One {\em cannot} write statements of
  the form ``if $f(x)$ loops, then ...'' in any algorithm,
  because termination is not detectable.
  Of course, one {\em can} write ``if $f(x)$ halts, then ... .''
  This asymmetry is quite fundamental, and underlies all the
  results pertaining to halting / acceptance.
  
\item One cannot examine the
 code (``program'') of a \TM and decide what its language is.
 More precisely, one cannot build a classifier program $Q$ that, given
 access only to \TM programs $P_m$ (which encode \TMs $m$), 
 classify the $m$'s into two bins (say ``good''
 and ``bad'') according to the language of $m$.
 Any such classifier will have to classify all \TMs as ``good''
 or all as ``bad, '' or itself be incapable of handling all \TM codes
 (not be {\em total}).
\end{list}

\subsection{Mapping reductions}
\label{sec:mapping-red}
%--
\begin{figure}[tbhp]
  \begin{center}
  \includegraphics[scale=0.6]{mapping-redn.pdf}
  \end{center}
  \caption{Illustration of mapping reduction $A\leq_M B$}
  \label{fig:mapping-redn}
\end{figure}
%
%--
\begin{figure}[t]
\begin{footnotesize}
  \begin{verbatim}
How a decider for A_TM is obtained:

Step 1: Here is the initial tape.
------------------------------------------------------------------
| M | w |
------------------------------------------------------------------

Step 2. Build M' and put it on the tape
------------------------------------------------------------------
| M | w | ..build M' that incorporates M here.. |
------------------------------------------------------------------

Step 3. Put w on the tape.
---------------------------------------------------------------------
| M | w | ..build M' that incorporates M here.. | ..put w here.. |
---------------------------------------------------------------------

Step 4. Run Halt_TM_decider on M' and w  and return its decision
---------------------------------------------------------------------
| M | w | ..build M' that incorporates M here.. | ..put w here.. |
---------------------------------------------------------------------
  \end{verbatim}
\end{footnotesize}
%
\begin{displaymath}
D_{Halt_{TM}}(M^{'},w) = \left\{ \begin{array}{lll}
                              accepts\; & \Rightarrow\; M^{'}\; halts\; on\; w\; \Rightarrow\; & M\; accepts\; w\\
			      rejects\; & \Rightarrow\; M^{'}\; doesn't\; halt\; on\; w\; \Rightarrow\; & M\; doesn't\; accept\; w
			      	\end{array}
                       \right.				
\end{displaymath}
%
\caption{How the mapping reduction from $A_{TM}$ to $Halt_{TM}$ works}
\label{fig:atm-halt-mr-picture}
\end{figure}
%--
\begin{figure}[thbp]  
\begin{footnotesize}
    \begin{verbatim}
      M'(x) {
        if x <> w then loop ; // could also goto reject_M' here
        Run M on w ;
        If M accepts w, goto accept_M' ;
        If M rejects w, goto reject_M' ; }

How a decider for E_TM is obtained:

Step 1: Build above M' and put it on the tape
------------------------------------------------------------------
| M | w | ..build M' that incorporates M and w here.. |
------------------------------------------------------------------

Step 2: Run E_TM_decider on M' and return its decision
------------------------------------------------------------------
| M | w | ..build M' that incorporates M and w here.. |
------------------------------------------------------------------
    \end{verbatim}
\end{footnotesize}
%
\begin{displaymath}
Decider_{E_{TM}}(M^{'}) = \left\{ \begin{array}{lll}
                              accepts\; & \Rightarrow\; L(M^{'})\; is\; empty\; \Rightarrow\; & M\; does\; not\; accept\; w\\
			      rejects\; & \Rightarrow\; L(M^{'})\; is\; not\; empty\; \Rightarrow\; & M\; accepts\; w
			      	\end{array}
                       \right.				
\end{displaymath}
%
\caption{Mapping reduction from $A_{TM}$ to $\overline{E_{TM}}$}
\label{fig:mr-atm-etm}
\end{figure}
%---
\begin{figure}[thbp]  
\begin{footnotesize}
    \begin{verbatim}
      M'(x) {
        if x is of the form 0^n 1^n then goto accept_M' ;
        Run M on w ;
        If M accepts w, goto accept_M' ;
        If M rejects w, goto reject_M' ; }
    \end{verbatim}
\end{footnotesize}
%
\begin{displaymath}
Decider_{Regular_{TM}}(M^{'}) = \left\{ \begin{array}{ll}
                              accepts\; &\Rightarrow\; L(M^{'})\; is\; regular \\
			     \ \ \Rightarrow\; Language\;is\Sigma^{'} & \Rightarrow\; M\; accepts\; w\\
			      rejects\; &\Rightarrow\; L(M^{'})\; is\; not\; regular\\
			     \ \ \Rightarrow\; Language\;is\;0^n1^n   & \Rightarrow\; M\; does\;not\;accept\; w
			      	\end{array}
                       \right.				
\end{displaymath}
\caption{Mapping reduction from $A_{TM}$ to $Regular_{TM}$}
\label{fig:mr-atm-regular-tm}
\end{figure}
%---
\index{Mapping reduction}
\index{Mapping reduction!$\leq_m$}
%

\noindent{\bf Definition:\/}
A {\em computable} function $f:\Sigma^{*}\rightarrow \Sigma^{*}$ is a mapping reduction
from $A\subseteq \Sigma^*$
into $B\subseteq \Sigma^*$ if for all $x\in\Sigma^*$, $x\in A \Leftrightarrow f(x)\in B$.
%


\noindent{\bf Definition:\/}
A polynomial-time mapping reduction $\leq_P$ is a mapping reduction where the
reduction function $f$ has polynomial-time asymptotic upper-bound
time complexity.\footnote{Using the familiar notation ${\cal O}(\ldots)$
 for asymptotic upper-bounds,
 polynomial-time means ${\cal O}(n^k)$ for an input of length $n$, and $k>1$.}

%
% \footnotetext{Using the familiar notation ${\cal O}(\ldots)$
%  for asymptotic upper-bounds,
%  polynomial-time means ${\cal O}(n^k)$ for an input of length $n$, and $k>1$.
%  See
% \cite{hop-ull-algo,moret-shapiro,cormen-rivest-leicerson-algo} for details.}

See Figure~\ref{fig:mapping-redn} which illustrates the general situation that $A$
maps into a subset denoted by $f(A)$ of $B$, and members of $A$ map into $f(A)$
while non-members of $A$ map outside of $B$ (that means they map outside of even
$B\setminus f(A)$).
%
Also note that $A$ and $B$ need not be disjoint sets, although they often are.
%
A mapping reduction can be (and usually is) a non-injection and non-surjection; {\em i.e.},
it can be many to one and not necessarily onto.
%
It is denoted by $\leq_m$.
%
By asserting $A\leq_m B$, the existence of an $f$ as described above
is also being asserted.

\noindent Typically mapping reductions are used as follows:
%
\begin{list}{$\bullet$}{\addtolength{\itemsep}{-1.6\itemsep}}
\item Let $A$ be a language known to be undecidable (``old'' or ``existing'' language).
\item Let $B$ be the language that must be shown to be undecidable (``new'' language).
\item Find a mapping reduction $f$ from $A$ into $B$.
\item Now, if $B$ has a decider $D_B$, then we can decide membership in $A$ as
 follows:
 \begin{list}{$-$}{\addtolength{\itemsep}{-1.6\itemsep}}
 \item On input $z$, in order to check if $z\in A$, find out if $D_B(f(z))$
    accepts or not. If it accepts, then $z\in A$, and if it rejects, then
    $z\notin A$.
 \end{list}
\end{list}
%

\subsubsection{Mapping Reduction From $A_{TM}$ to $Halt_{TM}$}
\label{sec:mapping-red-atm-halt-tm}
%--
We first illustrate mapping reductions by taking $A=A_{TM}$
and $B=Halt_{TM}$ with respect to Figure~\ref{fig:mapping-redn}.
%
Function $f$ takes a member of $A_{TM}$, namely a pair $\langle M,w\rangle$, as input,
and prints out $\langle M^{'},w \rangle$ on the tape as its output.
%
Function $f$, in effect, generates the {\em text} of the program $M^{'}$ from the
text of the program $M$.
%
Here is the makeup of $M^{'}$:
\begin{list}{}{\addtolength{\itemsep}{-1.7\itemsep}}
  \item $M^{'}(x)$ =
  \begin{list}{}{\addtolength{\itemsep}{-1.7\itemsep}}
    \item Run $M$ on $x$
    \item If the result is ``accept,'' then ``accept''
    \item If the result is ``reject,'' then loop
  \end{list}
\end{list}
%
Notice that the text of $M^{'}$ has ``spliced'' within itself
a copy of the text of program $M$ that was input.
%
Mapping reductions such as $f$ illustrated here need not
``run'' the program they manufacture; they simply accept a
program such as $M$, and a possible second input, such as $w$,
and manufacture another program $M^{'}$ (and also copy over $w$)
and then consider their task done!
%
The reason such a process turns out to be useful is for the following
reasons:
\begin{quote}
 Suppose someone were to provide a decider for $Halt_{TM}$.
 The mapping reduction $f$ then makes it possible to obtain a
 decider for $A_{TM}$.
 When given $\langle M,w\rangle$, this decider will obtain
 $\langle M^{'},w\rangle = f(\langle M,w\rangle)$, and
 then feed it to the decider for $Halt_{TM}$.
\end{quote}

We have to carefully argue that $f$ is a mapping reduction.
We will be quite loose about the argument types of $f$ (namely that
it maps $\Sigma^{*}$ to $\Sigma^{*}$; we will assume that
any $\langle M,w\rangle$ pair can be thought to be a string,
and hence a member of a suitable $\Sigma^{*}$.
The proof itself is depicted in Figure~\ref{fig:atm-halt-mr-picture}.

\subsubsection{Mapping reduction From $A_{TM}$ to $E_{TM}$}
\label{sec:mapping-red-atm-cfl-tm}
%--
We show that 
\[ E_{TM} = \{ \langle M\rangle \;\mid\; {\rm M\; is\; a\; TM\; and\;}L(M)=\emptyset \} \]
is undecidable through a mapping reduction
that maps  $\langle M,w\rangle$ into $\langle M^{'}\rangle$, as
explained in Figure~\ref{fig:mr-atm-etm}.
%
\index{$E_{TM}$}

\subsubsection{Mapping reduction from $A_{TM}$ to $Regular_{TM}$}
\label{sec:mapping-red-regular-tm}
%--
\noindent Similarly, we can prove $Regular_{TM}$ to be undecidable
 by building the $M^{'}$ shown in Figure~\ref{fig:mr-atm-regular-tm}.

\subsection{Undecidable problems are ``$A_{TM}$ in disguise''}
\label{sec:atm-disguise}
%--
%
The techniques discussed here lie at the core of the notion of ``problem solving'' in that they
help identify which problems possess algorithms and which do not.

Undecidable problems are $A_{TM}$ in disguise.
%
We leave you with this thought, hoping that it will provide you with useful intuitions.
%
\index{$Regular_{TM}$}
%...................................
\clearpage

\end{document}


%--\end{compactitem}
%--\end{document}