Paper/Paper.thy
changeset 141 4d7a568bd911
parent 140 7f5243700f25
child 142 21c7139ffa07
equal deleted inserted replaced
140:7f5243700f25 141:4d7a568bd911
   227 In this paper we take on this daunting prospect and provide a
   227 In this paper we take on this daunting prospect and provide a
   228 formalisation of Turing machines, as well as abacus machines (a kind
   228 formalisation of Turing machines, as well as abacus machines (a kind
   229 of register machines) and recursive functions. To see the difficulties
   229 of register machines) and recursive functions. To see the difficulties
   230 involved with this work, one has to understand that Turing machine
   230 involved with this work, one has to understand that Turing machine
   231 programs can be completely \emph{unstructured}, behaving similar to
   231 programs can be completely \emph{unstructured}, behaving similar to
   232 Basic programs containing the infamous gotos \cite{Dijkstra68}. This
   232 Basic programs containing the infamous goto \cite{Dijkstra68}. This
   233 precludes in the general case a compositional Hoare-style reasoning
   233 precludes in the general case a compositional Hoare-style reasoning
   234 about Turing programs.  We provide such Hoare-rules for when it
   234 about Turing programs.  We provide such Hoare-rules for when it
   235 \emph{is} possible to reason in a compositional manner (which is
   235 \emph{is} possible to reason in a compositional manner (which is
   236 fortunately quite often), but also tackle the more complicated case
   236 fortunately quite often), but also tackle the more complicated case
   237 when we translate abacus programs into Turing programs.  This
   237 when we translate abacus programs into Turing programs.  This
   316 turn recursive functions to abacus machines. The universal Turing
   316 turn recursive functions to abacus machines. The universal Turing
   317 machine can then be constructed as a recursive function.
   317 machine can then be constructed as a recursive function.
   318 
   318 
   319 \smallskip
   319 \smallskip
   320 \noindent
   320 \noindent
   321 {\bf Contributions:} We formalised in Isabelle/HOL Turing machines following the
   321 {\bf Contributions:} We formalised in Isabelle/HOL Turing machines
   322 description of Boolos et al \cite{Boolos87} where tapes only have blank or
   322 following the description of Boolos et al \cite{Boolos87} where tapes
   323 occupied cells. We mechanise the undecidability of the halting problem and
   323 only have blank or occupied cells. We mechanise the undecidability of
   324 prove the correctness of concrete Turing machines that are needed
   324 the halting problem and prove the correctness of concrete Turing
   325 in this proof; such correctness proofs are left out in the informal literature.  
   325 machines that are needed in this proof; such correctness proofs are
   326 For reasoning about Turing machine programs we derive Hoare-rules.
   326 left out in the informal literature.  For reasoning about Turing
   327 We also construct the universal Turing machine from \cite{Boolos87} by
   327 machine programs we derive Hoare-rules.  We also construct the
   328 translating recursive functions to abacus machines and abacus machines to
   328 universal Turing machine from \cite{Boolos87} by translating recursive
   329 Turing machines. Since we have set up in Isabelle/HOL a very general computability
   329 functions to abacus machines and abacus machines to Turing
   330 model and undecidability result, we are able to formalise other
   330 machines. When formalising the universal Turing machine,
   331 results: we describe a proof of the computational equivalence
   331 we stumbled upon an inconsistence use of the definition of
   332 of single-sided Turing machines, which is not given in \cite{Boolos87},
   332 what function a Turing machine calculates. Since we have set up in
   333 but needed for example for formalising the undecidability proof of 
   333 Isabelle/HOL a very general computability model and undecidability
   334 Wang's tiling problem \cite{Robinson71}.
   334 result, we are able to formalise other results: we describe a proof of
   335 %We are not aware of any other
   335 the computational equivalence of single-sided Turing machines, which
   336 %formalisation of a substantial undecidability problem.
   336 is not given in \cite{Boolos87}, but needed for example for
       
   337 formalising the undecidability proof of Wang's tiling problem
       
   338 \cite{Robinson71}.  %We are not aware of any other %formalisation of a
       
   339 substantial undecidability problem.
   337 *}
   340 *}
   338 
   341 
   339 section {* Turing Machines *}
   342 section {* Turing Machines *}
   340 
   343 
   341 text {* \noindent
   344 text {* \noindent
   745   @{thm (lhs) nats2tape(3)} & @{text "\<equiv>"} & @{thm (rhs) nats2tape(3)}
   748   @{thm (lhs) nats2tape(3)} & @{text "\<equiv>"} & @{thm (rhs) nats2tape(3)}
   746   \end{tabular}}\label{standard}
   749   \end{tabular}}\label{standard}
   747   \end{equation}
   750   \end{equation}
   748   %
   751   %
   749   \noindent
   752   \noindent
   750   A \emph{standard tape} is then of the form @{text "(Bk\<^isup>l,\<langle>[n\<^isub>1,...,n\<^isub>m]\<rangle>)"} for some @{text l} 
   753   A \emph{standard tape} is then of the form @{text "(Bk\<^isup>k,\<langle>[n\<^isub>1,...,n\<^isub>m]\<rangle> @ Bk\<^isup>l)"} for some @{text k}, 
       
   754   @{text l} 
   751   and @{text "n\<^bsub>1...m\<^esub>"}. Note that the head in a standard tape ``points'' to the 
   755   and @{text "n\<^bsub>1...m\<^esub>"}. Note that the head in a standard tape ``points'' to the 
   752   leftmost @{term "Oc"} on the tape. Note also that the natural number @{text 0} 
   756   leftmost @{term "Oc"} on the tape. Note also that the natural number @{text 0} 
   753   is represented by a single filled cell on a standard tape, @{text 1} by two filled cells and so on.
   757   is represented by a single filled cell on a standard tape, @{text 1} by two filled cells and so on.
   754 
   758 
   755   Before we can prove the undecidability of the halting problem for
   759   Before we can prove the undecidability of the halting problem for
   975   \end{tabular}
   979   \end{tabular}
   976   \end{center}
   980   \end{center}
   977 
   981 
   978   \noindent
   982   \noindent
   979   This invariant depends on @{term n} representing the number of
   983   This invariant depends on @{term n} representing the number of
   980   @{term Oc}s@{text "+1"} (or encoded number) on the tape. It is not hard (26
   984   @{term Oc}s on the tape. It is not hard (26
   981   lines of automated proof script) to show that for @{term "n >
   985   lines of automated proof script) to show that for @{term "n >
   982   (0::nat)"} this invariant is preserved under the computation rules
   986   (0::nat)"} this invariant is preserved under the computation rules
   983   @{term step} and @{term steps}. This gives us partial correctness
   987   @{term step} and @{term steps}. This gives us partial correctness
   984   for @{term "tcopy_begin"}. 
   988   for @{term "tcopy_begin"}. 
   985 
   989