\documentstyle[11pt,twoside,psfig]{article}
\input{defs-6045}
\newcommand{\mless}{\leq_m}
\newcommand{\meq}{\equiv_m}
\newcommand{\tile}{\mbox{ Tiling Problem }}
\newtheorem{prop}[theorem]{Proposition}


\begin{document}

\handout{lecture21}{Notes on Lecture 21}{March 31, 1992}

%\reading{}

\section{Some Examples about the Use of Rice's Theorem}
The goal of this section is to illustrate the fact that Rice's theorem
cannot be used  to answer  whether all languages
of the type $\{M : M$ has property ${\cal P}_0\}$ are decidable or not.
Recall in effect that the domain of applicability of Rice's
theorem is to prove the {\em non}-recursiveness of
languages of the type
$\{M : L(M)$ has property ${\cal P}_0\}$ in the case
where ${\cal P}_0$ is a {\em non-trivial} property
of r.e. {\em languages}.

\begin{newexamp}[Example of the use of Rice's theorem]\mbox{ }\\
$L_1 = \{M : M $ halts on at least 100 distinct strings$\}$ is undecidable. Indeed
$L_1 = \{M : |L(M)| \geq 100\}$ so that Rice's theorem applies.
\end{newexamp}

On the other hand consider the following seemingly very similar example:

\begin{newexamp}[Example of a property that is not a language property]\mbox{ }\\
$L_2 = \{M : M $ has at least 100 states $\}$. $L_2$ {\em is} recursive:
given the encoding $e(M)$ of a Turing machine $M$ we can easily
count the number of states that $M$ has and decide whether $M$ is in $L_2$ or not.
This fact does not constitute though a contradiction to Rice's theorem:
in effect the property ``$M $ has at least 100 states'' is {\em not} a language
property. Actually, for any r.e. language $L$ there exists a machine $M$ 
having more then 100 states and such that
$L = L(M)$ (we can always had ``dummy'' states!). As a consequence, we could come
up with the example of a language $L$ 
accepted by some machine $M_1$ having less then 100 states and also by a machine
$M_2$ having more then 100 states.
\end{newexamp}

\begin{newexamp}[Another example of a property that is not a language property]\mbox{ }\\
$L_3 = \{M : M $ runs at most 35 steps on input 001$\}$. $L_2$ {is} also recursive:
indeed we can easily check whether any machine $M$ is in $L_3$
by running $M$ on the input 001 and waiting at most
for 36 steps.
\end{newexamp}

\begin{newexamp}[An undecidable language for which Rice's theorem does not apply]\mbox{ }\\
$L_4 = \{M : M $ halts on $\Lambda$ in a perfect square number of steps$\}$. 
\begin{claim} 
 The property  ``$M $ halts on $\Lambda$ in a perfect 
 square number of steps'' is not a language property (so that Rice's theorem
 does not apply) but
 $L_4$ {is}  nonetheless undecidable.
\end{claim}

\begin{proof}
\nopagebreak
\begin{itemize}
\item
We first show that 
``$ M $ halts on $\Lambda$ in a perfect square number of steps'' is not
a language property. Indeed, let $M_1$ be a machine in $L_4$. Consider the
machine $M_2$ that behaves on all inputs in the same way as $M_1$ except that 
it takes at the beginning an extra (dummy) step. Then $M_2 \not \in L_4$.
(This is because for every integer $n$ bigger or equal then 1,
$n$ and $n+1$ cannot be both perfect squares.) But $L(M_1)= L(M_2)$.

\item We show that $L_4$ is undecidable by proving that
$K_2\leq_m L_4$.

For this, consider the transformation 
$\phi: M \rightarrow M'$:
On any input $x\not = 0, M'$ halts immediately; for the input $x=\Lambda$
$M'$ simulates $M$ on $\Lambda$. If $M$ does not halt then $M'$ does not 
halt either. If $M$  does halt then $M'$ halts after having wasted some
extra steps (if necessary) so that the number of steps used in this
simulation is a perfect square. We see that the transformation
$\phi$ is recursive, and that $M$ halts on $\Lambda$ iff 
$M'$ halts on $\Lambda$ so that $M\in K_2$ iff $M'\in L_4$.
This proves that $K_2\leq_m L_4$. 
\end{itemize}
\end{proof}

\end{newexamp}



\begin{newexamp}[Example of a trivial language property]
$L_5 = \{M : L(M) $ is accepted by a Turing machine having an even number
of states$\}$. 

``$L(M) $ is accepted by a Turing machine having an even number
of states'' {\em is} a language property. It then seems that an
application of Rice's theorem yields that $L_5$ is undecidable.
But this is {\em not} the case. In effect recall that Rice's
theorem requires the property of language to be a {non-trivial} property
of r.e. languages. This means that some r.e. set should have
this property and some not.

But {\em all} r.e. sets $L$ are accepted by a turing machine 
having an even number of states:
by assumptions $\exists M_1$ s.t. $L= L(M_1)$.
If $M_1$ has an even number of states we are done. Else
consider $M_2$ which is like $M_1$ but has an extra dummy state.

Hence $L_5$ is the set of all (encodings of) Turing machines, and is recursive.

\end{newexamp}



\begin{newexamp}
$L_6 = \{M : L(M) $ is accepted by a Turing machine having less then
10 states and less then 10 tape symbols $\}$. 

The property in $L_6$ is a language property. It is a non-trivial property
for there are some r.e. sets having this property and some others that
do not have it. Hence Rice's theorem applies and $L_6$ is not decidable.
\end{newexamp}

\section{Tiling Problems}
\subsection{The Different Versions of the Problem}
We now consider a new kind of problems. The question is to know
whether there exists a general program which, presented on the one hand with an
open box containing a jigsaw puzzle (containing possibly infinitely 
many parts), and on the other hand with a (big) frame,
 can decide whether the frame can be totally 
covered using some of (not necessarily all) the parts.

At this point the question is still vague and we will make it more
precise. To begin we will assume that a pattern recognition program
is able to recognize the nature of each part, so that for all
purposes here, we can consider the   abstract  model where
all the parts of the jigsaw are squares of the
same size (we will call them {\em tiles})
having each side colored by a (possibly different) color. Two 
adjacent tiles are then required to share the same color on their
common side.


Assume that the tiling problem we want to solve is to know whether
a finite frame of size $n$ can be tiled by a given set of $n$ tiles.
This means that the input of the program is the (description of the)
set of tiles and (of the) the frame. This problem is obviously decidable:
we just need to search through all $n!$ possibilities ($4^n n!$ if we are allowed
to rotate the tiles) to see whether one of them tiles the frame. (Recall
that time is not an issue here!)

Assume now that we are interested by the infinite version of this problem
where the size of the frame is infinite. For the problem to be meaningful 
from a computer science point of view, we need to deal only with finite
inputs so that we will consider the case where we have an infinite
supply of tiles belonging to a {\em finite} set of ``types''. For instance
a type of tile would be the set of tiles that are red on 
all four  sides, another would be the type of tiles red on top and bottom,
blue on the left and green on the right...
Without loss of generality we can also restrict ourselves
to the case where rotation are not allowed. The tiling problem we consider is then:

{\bf Two dimensional tiling problem:} ``Given a finite set of tiles, can we tile
the upper right quadrant of the plane?'' 

Recall that by ``finite set'' we mean actually a finite set of {\em types}
and that for each type we have an infinite supply of tiles. Also, we do not need
to use infinitely many (or even  any) tiles of each type: the problem is just to use
some tiles from our supplies and cover the {\em whole} quadrant.

An equivalent problem is the following (By ``equivalent'' we mean that
 a program able to solve one problem can
be modified to solve the other one):

{\bf Two dimensional tiling problem with preassigned origin:} 
``Given a finite set of tiles, can we tile
the upper right quadrant of the plane in such a way that the corner is
a tile of a preassigned type?'' 

To get a feeling for that problem, we first consider the:

{\bf One dimensional tiling problem with preassigned origin:} 
 ``Given a finite set of tiles, can we tile
the  (one dimensional) infinite strip, in such a way that the corner is
a tile of a preassigned type?'' 


\begin{figure}[ht]
\centerline{\mbox{\psfig{figure=/hand29-fig1.ps,height=3in}}}
\caption{Example of a One-dimensional Tiling Problem}
\label{fig:one_dim}
\end{figure}

Consider the example of Figure~\ref{fig:one_dim}. In this example we have four types of tiles,
and the colors are symbolized by letters. We can represent the adjacency compatibilities
by a DFA: each tile corresponds to a state and there is an arrow from state $i$ to state $j$
exactly when the right side of tile $i$ has the same color as the left side of tile $j$.
We see that the one-dimensional strip is tilable iff there is a cycle in the DFA
which is reachable from the start state. In the case of the example of
Figure~\ref{fig:one_dim} we deduce that the pattern 1 32 32 32... tiles the strip.

\subsection{The Two-Dimensional Tiling Problem}

Is the two dimensional tiling problem also decidable?
\begin{theorem}
The two dimensional tiling problem is not decidable.
\end{theorem}

\begin{proof}
We will prove that $\overline{K_2} \mless \tile$. This means 
that we will associate in a recursive way a tiling problem ${\cal T}_M$
 to any turing machine M in such a way that  $M$ halts on $\Lambda$
iff there is no tiling of the quadrant in ${\cal T}_M$.
In more details this means that if $M$ halts then there is a tiling in
${\cal T}_M$; 
and if $M$ does not halts then there is no tiling in ${\cal T}_M$.

First we define some terminology:
by convention a row of tiles  is in between two lines. (See
Figure~\ref{fig:two_dim:0}.)

\begin{figure}[ht]
\centerline{\mbox{\psfig{figure=/hand29-figg-0.ps,height=.5in}}}
\caption{Rows and Lines}
\label{fig:two_dim:0}
\end{figure}


The idea is that each line 
 of the frame will represent a configuration 
of the Turing machine;  each  row of tile will represent a step
of the computation performed by $M$. (So that we can think that the time
is represented vertically.) 
Hence, in this representation, we will be able to tile the whole quadrant
iff there is a tiling for every row i.e, iff the Turing machine never halts.

We will have 5 types of tiles. 
\begin{enumerate}
\item The tiles illustrated in Figure~\ref{fig:two_dim:1} simply communicate
unchanged letters upwards from configuration to configuration.

\begin{figure}[ht]
\centerline{\mbox{\psfig{figure=/hand29-figg-1.ps,height=1in}}}
\caption{Tiles copying the tape}
\label{fig:two_dim:1}
\end{figure}

\item The tiles illustrated in Figure~\ref{fig:two_dim:2} 
express that $\delta(p,a)= (q,b,S)$.

\begin{figure}[ht]
\centerline{\mbox{\psfig{figure=/hand29-figg-2.ps,height=1in}}}
\caption{Tiles expressing $\delta(p,a)= (q,b,S)$}
\label{fig:two_dim:2}
\end{figure}


\item The tiles illustrated in Figure~\ref{fig:two_dim:3} 
express that $\delta(p,a)= (q,b,R)$. The tiles communicate head movement
one square from left to right while changing the state correctly.

\begin{figure}[ht]
\centerline{\mbox{\psfig{figure=/hand29-figg-3.ps,height=1in}}}
\caption{Tiles expressing $\delta(p,a)= (q,b,R)$}
\label{fig:two_dim:3}
\end{figure}

\item The tiles illustrated in Figure~\ref{fig:two_dim:4} 
express that $\delta(p,a)= (q,b,L)$. They are similar then to the tiles  of 
case 3.

\begin{figure}[ht]
\centerline{\mbox{\psfig{figure=/hand29-figg-4.ps,height=1in}}}
\caption{Tiles expressing $\delta(p,a)= (q,b,L)$}
\label{fig:two_dim:4}
\end{figure}

\item The origin tile is  illustrated in Figure~\ref{fig:two_dim:5}~(a).
The only tiles that can go on its right are the tiles 
 illustrated in Figure~\ref{fig:two_dim:5}~(b).

\begin{figure}[ht]
\centerline{\mbox{\psfig{figure=/hand29-figg-5.ps,height=1in}}}
\caption{Origin Tile and Blank Tiles}
\label{fig:two_dim:5}
\end{figure}

\end{enumerate}

This completes the description of ${\cal T}_M$. Note
that each line of the tiling contains exactly  one couple $(p,b)$ indicating
the state and the position of the head. Note also that no tile
mentions the halt state so that if $M$ halts after $k$ steps 
then only $k$ rows can be tiled.
\end{proof}



\end{document}
