Paper.thy
changeset 20 ae3d568b887b
parent 19 7971da47e8c4
child 21 c5e3007fed2a
equal deleted inserted replaced
19:7971da47e8c4 20:ae3d568b887b
   115 structural and non-structural, ``worlds'' when formalising the
   115 structural and non-structural, ``worlds'' when formalising the
   116 Myhill-Nerode theorem, where regular expressions fared much better
   116 Myhill-Nerode theorem, where regular expressions fared much better
   117 than automata \cite{WuZhangUrban11}.  However, with Turing machines
   117 than automata \cite{WuZhangUrban11}.  However, with Turing machines
   118 there seems to be no alternative if one wants to formalise the great
   118 there seems to be no alternative if one wants to formalise the great
   119 many proofs from the literature that use them.  We will analyse one
   119 many proofs from the literature that use them.  We will analyse one
   120 example---undecidability of Wang tilings---in Section~\ref{Wang}. The
   120 example---undecidability of Wang's tiling problem---in Section~\ref{Wang}. The
   121 standard proof of this property uses the notion of \emph{universal
   121 standard proof of this property uses the notion of \emph{universal
   122 Turing machines}.
   122 Turing machines}.
   123 
   123 
   124 We are not the first who formalised Turing machines in a theorem
   124 We are not the first who formalised Turing machines in a theorem
   125 prover: we are aware of the preliminary work by Asperti and Ricciotti
   125 prover: we are aware of the preliminary work by Asperti and Ricciotti
   155 \end{quote}
   155 \end{quote}
   156 
   156 
   157 \noindent
   157 \noindent
   158 In this paper we follow the approach by Boolos et al \cite{Boolos87},
   158 In this paper we follow the approach by Boolos et al \cite{Boolos87},
   159 which goes back to Post \cite{Post36}, where all Turing machines
   159 which goes back to Post \cite{Post36}, where all Turing machines
   160 operate on tapes that contain only \emph{blank} or \emph{filled} cells
   160 operate on tapes that contain only \emph{blank} or \emph{occupied} cells
   161 (represented by @{term Bk} and @{term Oc}, respectively, in our
   161 (represented by @{term Bk} and @{term Oc}, respectively, in our
   162 formalisation). Traditionally the content of a cell can be any
   162 formalisation). Traditionally the content of a cell can be any
   163 character from a finite alphabet. Although computationally equivalent,
   163 character from a finite alphabet. Although computationally equivalent,
   164 the more restrictive notion of Turing machines in \cite{Boolos87} makes
   164 the more restrictive notion of Turing machines in \cite{Boolos87} makes
   165 the reasoning more uniform. In addition some proofs \emph{about} Turing
   165 the reasoning more uniform. In addition some proofs \emph{about} Turing
   166 machines will be simpler.  The reason is that one often need to encode
   166 machines will be simpler.  The reason is that one often needs to encode
   167 Turing machines---if the Turing machines are simpler, then the coding
   167 Turing machines---consequently if the Turing machines are simpler, then the coding
   168 functions are simpler. Unfortunately, the restrictiveness also makes
   168 functions are simpler too. Unfortunately, the restrictiveness also makes
   169 it harder to design programs for these Turing machines. Therefore in order
   169 it harder to design programs for these Turing machines. Therefore in order
   170 to construct a \emph{universal Turing machine} we follow the proof in
   170 to construct a \emph{universal Turing machine} we follow the proof in
   171 \cite{Boolos87} by relating abacus machines to Turing machines and in
   171 \cite{Boolos87} by relating abacus machines to Turing machines and in
   172 turn recursive functions to abacus machines. The universal Turing
   172 turn recursive functions to abacus machines. The universal Turing
   173 machine can then be constructed as recursive function.
   173 machine can then be constructed as a recursive function.
   174 
   174 
   175 \smallskip
   175 \smallskip
   176 \noindent
   176 \noindent
   177 {\bf Contributions:} 
   177 {\bf Contributions:} 
   178 
   178 
   179 *}
   179 *}
   180 
   180 
   181 section {* Turing Machines *}
   181 section {* Turing Machines *}
   182 
   182 
   183 text {*
   183 text {* \noindent
   184   \noindent
   184   Turing machines can be thought of as having a read-write-unit
   185   Turing machines can be thought of as having read-write-unit
       
   186   ``gliding'' over a potentially infinite tape. Boolos et
   185   ``gliding'' over a potentially infinite tape. Boolos et
   187   al~\cite{Boolos87} only consider tapes with cells being either blank
   186   al~\cite{Boolos87} only consider tapes with cells being either blank
   188   or occupied, which we represent with a datatype having two
   187   or occupied, which we represent by a datatype having two
   189   constructors, namely @{text Bk} and @{text Oc}.  One easy way to
   188   constructors, namely @{text Bk} and @{text Oc}.  One way to
   190   represent such tapes is to use a pair of lists, written @{term "(l,
   189   represent such tapes is to use a pair of lists, written @{term "(l,
   191   r)"}, where @{term l} stands for the tape on the left of the
   190   r)"}, where @{term l} stands for the tape on the left-hand side of the
   192   read-write-unit and @{term r} for the tape on the right. We have the
   191   read-write-unit and @{term r} for the tape on the right-hand side. We have the
   193   convention that the head, written @{term hd}, of the right-list is
   192   convention that the head, written @{term hd}, of the right-list is
   194   the cell on which the read-write-unit currently operates. This can
   193   the cell on which the read-write-unit currently operates. This can
   195   be pictured as follows:
   194   be pictured as follows:
   196 
   195 
   197   \begin{center}
   196   \begin{center}
   236   & $\mid$ & @{term Nop} & do-nothing operation\\
   235   & $\mid$ & @{term Nop} & do-nothing operation\\
   237   \end{tabular}
   236   \end{tabular}
   238   \end{center}
   237   \end{center}
   239 
   238 
   240   \noindent
   239   \noindent
   241   By using the @{term Nop} operation, we slightly deviate
   240   We slightly deviate
   242   from the presentation in \cite{Boolos87}; however its use
   241   from the presentation in \cite{Boolos87} by using the @{term Nop} operation; however its use
   243   will become important when we formalise universal Turing 
   242   will become important when we formalise universal Turing 
   244   machines. Given a tape and an action, we can define the
   243   machines later. Given a tape and an action, we can define the
   245   following updating function:
   244   following updating function:
   246 
   245 
   247   \begin{center}
   246   \begin{center}
   248   \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l}
   247   \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l}
   249   @{thm (lhs) new_tape_def2(1)} & @{text "\<equiv>"} & @{thm (rhs) new_tape_def2(1)}\\
   248   @{thm (lhs) new_tape_def2(1)} & @{text "\<equiv>"} & @{thm (rhs) new_tape_def2(1)}\\
   250   @{thm (lhs) new_tape_def2(2)} & @{text "\<equiv>"} & @{thm (rhs) new_tape_def2(2)}\\
   249   @{thm (lhs) new_tape_def2(2)} & @{text "\<equiv>"} & @{thm (rhs) new_tape_def2(2)}\\
   251   @{thm (lhs) new_tape_def2(3)} & @{text "\<equiv>"} & \\
   250   @{thm (lhs) new_tape_def2(3)} & @{text "\<equiv>"} & \\
   252   \multicolumn{3}{p{3cm}}{\hspace{1cm}@{thm (rhs) new_tape_def2(3)}}\\
   251   \multicolumn{3}{l}{\hspace{1cm}@{thm (rhs) new_tape_def2(3)}}\\
   253   @{thm (lhs) new_tape_def2(4)} & @{text "\<equiv>"} & \\
   252   @{thm (lhs) new_tape_def2(4)} & @{text "\<equiv>"} & \\
   254   \multicolumn{3}{p{2cm}}{\hspace{1cm}@{thm (rhs) new_tape_def2(4)}}\\
   253   \multicolumn{3}{l}{\hspace{1cm}@{thm (rhs) new_tape_def2(4)}}\\
   255   @{thm (lhs) new_tape_def2(5)} & @{text "\<equiv>"} & @{thm (rhs) new_tape_def2(5)}\\
   254   @{thm (lhs) new_tape_def2(5)} & @{text "\<equiv>"} & @{thm (rhs) new_tape_def2(5)}\\
   256   \end{tabular}
   255   \end{tabular}
   257   \end{center}
   256   \end{center}
   258 
   257 
   259   \noindent
   258   \noindent