author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Sat, 19 Jan 2013 12:45:14 +0000 | |
changeset 52 | 2cb1e4499983 |
parent 50 | 816e84ca16d6 |
child 61 | 7edbd5657702 |
permissions | -rw-r--r-- |
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
(*<*) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
theory Paper |
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
3 |
imports "../thys/uncomputable" |
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
begin |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
|
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
6 |
(* |
25
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
7 |
hide_const (open) s |
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
8 |
*) |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
9 |
|
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
10 |
|
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
11 |
hide_const (open) Divides.adjust |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
12 |
|
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
13 |
abbreviation |
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
14 |
"update2 p a \<equiv> update a p" |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
15 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
16 |
consts DUMMY::'a |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
17 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
18 |
notation (latex output) |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
19 |
Cons ("_::_" [78,77] 73) and |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
20 |
set ("") and |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
21 |
W0 ("W\<^bsub>\<^raw:\hspace{-2pt}>Bk\<^esub>") and |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
22 |
W1 ("W\<^bsub>\<^raw:\hspace{-2pt}>Oc\<^esub>") and |
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
23 |
update2 ("update") and |
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
24 |
(* abc_lm_v ("lookup") and |
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
25 |
abc_lm_s ("set") and*) |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
26 |
haltP ("stdhalt") and |
37
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
27 |
tcopy ("copy") and |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
28 |
tape_of_nat_list ("\<ulcorner>_\<urcorner>") and |
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
29 |
tm_comp ("_ \<oplus> _") and |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
30 |
DUMMY ("\<^raw:\mbox{$\_$}>") |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
31 |
|
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
declare [[show_question_marks = false]] |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
(*>*) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
35 |
section {* Introduction *} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
36 |
|
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
37 |
|
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
38 |
|
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
39 |
text {* |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
40 |
|
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
41 |
%\noindent |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
42 |
%We formalised in earlier work the correctness proofs for two |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
43 |
%algorithms in Isabelle/HOL---one about type-checking in |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
44 |
%LF~\cite{UrbanCheneyBerghofer11} and another about deciding requests |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
45 |
%in access control~\cite{WuZhangUrban12}. The formalisations |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
46 |
%uncovered a gap in the informal correctness proof of the former and |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
47 |
%made us realise that important details were left out in the informal |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
48 |
%model for the latter. However, in both cases we were unable to |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
49 |
%formalise in Isabelle/HOL computability arguments about the |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
50 |
%algorithms. |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
51 |
|
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
52 |
|
8
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
53 |
\noindent |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
54 |
Suppose you want to mechanise a proof about whether a predicate @{term P}, say, is |
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
55 |
decidable or not. Decidability of @{text P} usually amounts to showing |
8
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
56 |
whether \mbox{@{term "P \<or> \<not>P"}} holds. But this does \emph{not} work |
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
57 |
in Isabelle/HOL and other HOL theorem provers, since they are based on classical logic |
8
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
58 |
where the law of excluded middle ensures that \mbox{@{term "P \<or> \<not>P"}} |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
59 |
is always provable no matter whether @{text P} is constructed by |
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
60 |
computable means. |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
61 |
|
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
62 |
%The same problem would arise if we had formulated |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
63 |
%the algorithms as recursive functions, because internally in |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
64 |
%Isabelle/HOL, like in all HOL-based theorem provers, functions are |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
65 |
%represented as inductively defined predicates too. |
8
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
66 |
|
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
67 |
The only satisfying way out of this problem in a theorem prover based |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
68 |
on classical logic is to formalise a theory of computability. Norrish |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
69 |
provided such a formalisation for the HOL4. He choose |
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
70 |
the $\lambda$-calculus as the starting point for his formalisation of |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
71 |
computability theory, because of its ``simplicity'' \cite[Page |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
72 |
297]{Norrish11}. Part of his formalisation is a clever infrastructure |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
73 |
for reducing $\lambda$-terms. He also established the computational |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
74 |
equivalence between the $\lambda$-calculus and recursive functions. |
52
2cb1e4499983
updated before_final
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
50
diff
changeset
|
75 |
Nevertheless he concluded that it would be appealing |
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
76 |
to have formalisations for more operational models of |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
77 |
computations, such as Turing machines or register machines. One |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
78 |
reason is that many proofs in the literature use them. He noted |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
79 |
however that \cite[Page 310]{Norrish11}: |
8
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
80 |
|
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
81 |
\begin{quote} |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
82 |
\it``If register machines are unappealing because of their |
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
83 |
general fiddliness,\\ Turing machines are an even more |
8
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
84 |
daunting prospect.'' |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
85 |
\end{quote} |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
86 |
|
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
87 |
\noindent |
33
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
88 |
In this paper we take on this daunting prospect and provide a |
13
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
89 |
formalisation of Turing machines, as well as abacus machines (a kind |
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
90 |
of register machines) and recursive functions. To see the difficulties |
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
91 |
involved with this work, one has to understand that Turing machine |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
92 |
programs can be completely \emph{unstructured}, behaving |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
93 |
similar to Basic's infamous goto \cite{Dijkstra68}. This precludes in the |
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
94 |
general case a compositional Hoare-style reasoning about Turing |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
95 |
programs. We provide such Hoare-rules for when it is possible to |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
96 |
reason in a compositional manner (which is fortunately quite often), but also tackle |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
97 |
the more complicated case when we translate abacus programs into |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
98 |
Turing programs. This aspect of reasoning about computability theory |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
99 |
is usually completely left out in the informal literature, e.g.~\cite{Boolos87}. |
12
dd400b5797e1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
10
diff
changeset
|
100 |
|
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
101 |
%To see the difficulties |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
102 |
%involved with this work, one has to understand that interactive |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
103 |
%theorem provers, like Isabelle/HOL, are at their best when the |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
104 |
%data-structures at hand are ``structurally'' defined, like lists, |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
105 |
%natural numbers, regular expressions, etc. Such data-structures come |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
106 |
%with convenient reasoning infrastructures (for example induction |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
107 |
%principles, recursion combinators and so on). But this is \emph{not} |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
108 |
%the case with Turing machines (and also not with register machines): |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
109 |
%underlying their definitions are sets of states together with |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
110 |
%transition functions, all of which are not structurally defined. This |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
111 |
%means we have to implement our own reasoning infrastructure in order |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
112 |
%to prove properties about them. This leads to annoyingly fiddly |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
113 |
%formalisations. We noticed first the difference between both, |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
114 |
%structural and non-structural, ``worlds'' when formalising the |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
115 |
%Myhill-Nerode theorem, where regular expressions fared much better |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
116 |
%than automata \cite{WuZhangUrban11}. However, with Turing machines |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
117 |
%there seems to be no alternative if one wants to formalise the great |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
118 |
%many proofs from the literature that use them. We will analyse one |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
119 |
%example---undecidability of Wang's tiling problem---in Section~\ref{Wang}. The |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
120 |
%standard proof of this property uses the notion of universal |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
121 |
%Turing machines. |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
122 |
|
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
123 |
We are not the first who formalised Turing machines: we are aware |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
124 |
of the preliminary work by Asperti and Ricciotti |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
125 |
\cite{AspertiRicciotti12}. They describe a complete formalisation of |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
126 |
Turing machines in the Matita theorem prover, including a universal |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
127 |
Turing machine. They report that the informal proofs from which they |
37
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
128 |
started are \emph{not} ``sufficiently accurate to be directly usable as a |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
129 |
guideline for formalization'' \cite[Page 2]{AspertiRicciotti12}. For |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
130 |
our formalisation we followed mainly the proofs from the textbook |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
131 |
\cite{Boolos87} and found that the description there is quite |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
132 |
detailed. Some details are left out however: for example, it is only |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
133 |
shown how the universal Turing machine is constructed for Turing |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
134 |
machines computing unary functions. We had to figure out a way to |
37
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
135 |
generalise this result to $n$-ary functions. Similarly, when compiling |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
136 |
recursive functions to abacus machines, the textbook again only shows |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
137 |
how it can be done for 2- and 3-ary functions, but in the |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
138 |
formalisation we need arbitrary functions. But the general ideas for |
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
139 |
how to do this are clear enough in \cite{Boolos87}. |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
140 |
%However, one |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
141 |
%aspect that is completely left out from the informal description in |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
142 |
%\cite{Boolos87}, and similar ones we are aware of, is arguments why certain Turing |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
143 |
%machines are correct. We will introduce Hoare-style proof rules |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
144 |
%which help us with such correctness arguments of Turing machines. |
10
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
145 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
146 |
The main difference between our formalisation and the one by Asperti |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
147 |
and Ricciotti is that their universal Turing machine uses a different |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
148 |
alphabet than the machines it simulates. They write \cite[Page |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
149 |
23]{AspertiRicciotti12}: |
10
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
150 |
|
15
90bc8cccc218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
13
diff
changeset
|
151 |
\begin{quote}\it |
13
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
152 |
``In particular, the fact that the universal machine operates with a |
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
153 |
different alphabet with respect to the machines it simulates is |
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
154 |
annoying.'' |
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
155 |
\end{quote} |
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
156 |
|
15
90bc8cccc218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
13
diff
changeset
|
157 |
\noindent |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
158 |
In this paper we follow the approach by Boolos et al \cite{Boolos87}, |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
159 |
which goes back to Post \cite{Post36}, where all Turing machines |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
160 |
operate on tapes that contain only \emph{blank} or \emph{occupied} cells. |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
161 |
Traditionally the content of a cell can be any |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
162 |
character from a finite alphabet. Although computationally equivalent, |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
163 |
the more restrictive notion of Turing machines in \cite{Boolos87} makes |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
164 |
the reasoning more uniform. In addition some proofs \emph{about} Turing |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
165 |
machines are simpler. The reason is that one often needs to encode |
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
166 |
Turing machines---consequently if the Turing machines are simpler, then the coding |
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
167 |
functions are simpler too. Unfortunately, the restrictiveness also makes |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
168 |
it harder to design programs for these Turing machines. In order |
38
8f8db701f69f
updated contribution section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
169 |
to construct a universal Turing machine we therefore do not follow |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
170 |
\cite{AspertiRicciotti12}, instead follow the proof in |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
171 |
\cite{Boolos87} by relating abacus machines to Turing machines and in |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
172 |
turn recursive functions to abacus machines. The universal Turing |
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
173 |
machine can then be constructed as a recursive function. |
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
174 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
175 |
\smallskip |
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
176 |
\noindent |
38
8f8db701f69f
updated contribution section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
177 |
{\bf Contributions:} We formalised in Isabelle/HOL Turing machines following the |
8f8db701f69f
updated contribution section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
178 |
description of Boolos et al \cite{Boolos87} where tapes only have blank or |
8f8db701f69f
updated contribution section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
179 |
occupied cells. We mechanise the undecidability of the halting problem and |
8f8db701f69f
updated contribution section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
180 |
prove the correctness of concrete Turing machines that are needed |
8f8db701f69f
updated contribution section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
181 |
in this proof; such correctness proofs are left out in the informal literature. |
8f8db701f69f
updated contribution section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
182 |
We construct the universal Turing machine from \cite{Boolos87} by |
8f8db701f69f
updated contribution section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
183 |
relating recursive functions to abacus machines and abacus machines to |
8f8db701f69f
updated contribution section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
184 |
Turing machines. Since we have set up in Isabelle/HOL a very general computability |
8f8db701f69f
updated contribution section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
185 |
model and undecidability result, we are able to formalise the |
8f8db701f69f
updated contribution section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
186 |
undecidability of Wang's tiling problem. We are not aware of any other |
8f8db701f69f
updated contribution section
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
37
diff
changeset
|
187 |
formalisation of a substantial undecidability problem. |
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
188 |
*} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
189 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
190 |
section {* Turing Machines *} |
9
965df91a24bc
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
8
diff
changeset
|
191 |
|
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
192 |
text {* \noindent |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
193 |
Turing machines can be thought of as having a \emph{head}, |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
194 |
``gliding'' over a potentially infinite tape. Boolos et |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
195 |
al~\cite{Boolos87} only consider tapes with cells being either blank |
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
196 |
or occupied, which we represent by a datatype having two |
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
197 |
constructors, namely @{text Bk} and @{text Oc}. One way to |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
198 |
represent such tapes is to use a pair of lists, written @{term "(l, |
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
199 |
r)"}, where @{term l} stands for the tape on the left-hand side of the |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
200 |
head and @{term r} for the tape on the right-hand side. We have the |
33
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
201 |
convention that the head, abbreviated @{term hd}, of the right-list is |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
202 |
the cell on which the head of the Turing machine currently operates. This can |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
203 |
be pictured as follows: |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
204 |
% |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
205 |
\begin{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
206 |
\begin{tikzpicture} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
207 |
\draw[very thick] (-3.0,0) -- ( 3.0,0); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
208 |
\draw[very thick] (-3.0,0.5) -- ( 3.0,0.5); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
209 |
\draw[very thick] (-0.25,0) -- (-0.25,0.5); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
210 |
\draw[very thick] ( 0.25,0) -- ( 0.25,0.5); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
211 |
\draw[very thick] (-0.75,0) -- (-0.75,0.5); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
212 |
\draw[very thick] ( 0.75,0) -- ( 0.75,0.5); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
213 |
\draw[very thick] (-1.25,0) -- (-1.25,0.5); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
214 |
\draw[very thick] ( 1.25,0) -- ( 1.25,0.5); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
215 |
\draw[very thick] (-1.75,0) -- (-1.75,0.5); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
216 |
\draw[very thick] ( 1.75,0) -- ( 1.75,0.5); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
217 |
\draw[rounded corners=1mm] (-0.35,-0.1) rectangle (0.35,0.6); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
218 |
\draw[fill] (1.35,0.1) rectangle (1.65,0.4); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
219 |
\draw[fill] (0.85,0.1) rectangle (1.15,0.4); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
220 |
\draw[fill] (-0.35,0.1) rectangle (-0.65,0.4); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
221 |
\draw (-0.25,0.8) -- (-0.25,-0.8); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
222 |
\draw[<->] (-1.25,-0.7) -- (0.75,-0.7); |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
223 |
\node [anchor=base] at (-0.8,-0.5) {\small left list}; |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
224 |
\node [anchor=base] at (0.35,-0.5) {\small right list}; |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
225 |
\node [anchor=base] at (0.1,0.7) {\small head}; |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
226 |
\node [anchor=base] at (-2.2,0.2) {\ldots}; |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
227 |
\node [anchor=base] at ( 2.3,0.2) {\ldots}; |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
228 |
\end{tikzpicture} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
229 |
\end{center} |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
230 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
231 |
\noindent |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
232 |
Note that by using lists each side of the tape is only finite. The |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
233 |
potential infinity is achieved by adding an appropriate blank or occupied cell |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
234 |
whenever the head goes over the ``edge'' of the tape. To |
52
2cb1e4499983
updated before_final
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
50
diff
changeset
|
235 |
make this formal we define five possible \emph{actions}, @{text a} |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
236 |
the Turing machine can perform: |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
237 |
|
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
238 |
\begin{center} |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
239 |
\begin{tabular}[t]{@ {}rcl@ {\hspace{2mm}}l} |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
240 |
@{text "a"} & $::=$ & @{term "W0"} & (write blank, @{term Bk})\\ |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
241 |
& $\mid$ & @{term "W1"} & (write occupied, @{term Oc})\\ |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
242 |
\end{tabular} |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
243 |
\begin{tabular}[t]{rcl@ {\hspace{2mm}}l} |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
244 |
& $\mid$ & @{term L} & (move left)\\ |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
245 |
& $\mid$ & @{term R} & (move right)\\ |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
246 |
\end{tabular} |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
247 |
\begin{tabular}[t]{rcl@ {\hspace{2mm}}l@ {}} |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
248 |
& $\mid$ & @{term Nop} & (do-nothing operation)\\ |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
249 |
\end{tabular} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
250 |
\end{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
251 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
252 |
\noindent |
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
253 |
We slightly deviate |
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
254 |
from the presentation in \cite{Boolos87} by using the @{term Nop} operation; however its use |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
255 |
will become important when we formalise halting computations and also universal Turing |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
256 |
machines. Given a tape and an action, we can define the |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
257 |
following tape updating function: |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
258 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
259 |
\begin{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
260 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
261 |
@{thm (lhs) update.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) update.simps(1)}\\ |
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
262 |
@{thm (lhs) update.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) update.simps(2)}\\ |
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
263 |
@{thm (lhs) update.simps(3)} & @{text "\<equiv>"} & @{thm (rhs) update.simps(3)}\\ |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
264 |
@{thm (lhs) update.simps(4)} & @{text "\<equiv>"} & @{thm (rhs) update.simps(4)}\\ |
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
265 |
@{thm (lhs) update.simps(5)} & @{text "\<equiv>"} & @{thm (rhs) update.simps(5)}\\ |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
266 |
\end{tabular} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
267 |
\end{center} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
268 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
269 |
\noindent |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
270 |
The first two clauses replace the head of the right-list |
37
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
271 |
with a new @{term Bk} or @{term Oc}, respectively. To see that |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
272 |
these two clauses make sense in case where @{text r} is the empty |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
273 |
list, one has to know that the tail function, @{term tl}, is defined |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
274 |
such that @{term "tl [] == []"} holds. The third clause |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
275 |
implements the move of the head one step to the left: we need |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
276 |
to test if the left-list @{term l} is empty; if yes, then we just prepend a |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
277 |
blank cell to the right-list; otherwise we have to remove the |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
278 |
head from the left-list and prepend it to the right-list. Similarly |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
279 |
in the fourth clause for a right move action. The @{term Nop} operation |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
280 |
leaves the the tape unchanged. |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
281 |
|
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
282 |
%Note that our treatment of the tape is rather ``unsymmetric''---we |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
283 |
%have the convention that the head of the right-list is where the |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
284 |
%head is currently positioned. Asperti and Ricciotti |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
285 |
%\cite{AspertiRicciotti12} also considered such a representation, but |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
286 |
%dismiss it as it complicates their definition for \emph{tape |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
287 |
%equality}. The reason is that moving the head one step to |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
288 |
%the left and then back to the right might change the tape (in case |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
289 |
%of going over the ``edge''). Therefore they distinguish four types |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
290 |
%of tapes: one where the tape is empty; another where the head |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
291 |
%is on the left edge, respectively right edge, and in the middle |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
292 |
%of the tape. The reading, writing and moving of the tape is then |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
293 |
%defined in terms of these four cases. In this way they can keep the |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
294 |
%tape in a ``normalised'' form, and thus making a left-move followed |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
295 |
%by a right-move being the identity on tapes. Since we are not using |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
296 |
%the notion of tape equality, we can get away with the unsymmetric |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
297 |
%definition above, and by using the @{term update} function |
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
298 |
%cover uniformly all cases including corner cases. |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
299 |
|
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
300 |
Next we need to define the \emph{states} of a Turing machine. |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
301 |
%Given |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
302 |
%how little is usually said about how to represent them in informal |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
303 |
%presentations, it might be surprising that in a theorem prover we |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
304 |
%have to select carefully a representation. If we use the naive |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
305 |
%representation where a Turing machine consists of a finite set of |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
306 |
%states, then we will have difficulties composing two Turing |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
307 |
%machines: we would need to combine two finite sets of states, |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
308 |
%possibly renaming states apart whenever both machines share |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
309 |
%states.\footnote{The usual disjoint union operation in Isabelle/HOL |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
310 |
%cannot be used as it does not preserve types.} This renaming can be |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
311 |
%quite cumbersome to reason about. |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
312 |
We followed the choice made by \cite{AspertiRicciotti12} |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
313 |
representing a state by a natural number and the states of a Turing |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
314 |
machine by the initial segment of natural numbers starting from @{text 0}. |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
315 |
In doing so we can compose two Turing machine by |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
316 |
shifting the states of one by an appropriate amount to a higher |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
317 |
segment and adjusting some ``next states'' in the other. {\it composition here?} |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
318 |
|
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
319 |
An \emph{instruction} @{term i} of a Turing machine is a pair consisting of |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
320 |
an action and a natural number (the next state). A \emph{program} @{term p} of a Turing |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
321 |
machine is then a list of such pairs. Using as an example the following Turing machine |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
322 |
program, which consists of four instructions |
29
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
323 |
|
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
324 |
\begin{equation} |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
325 |
\begin{tikzpicture} |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
326 |
\node [anchor=base] at (0,0) {@{thm dither_def}}; |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
327 |
\node [anchor=west] at (-1.5,-0.42) {$\underbrace{\hspace{21mm}}_{\text{1st state}}$}; |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
328 |
\node [anchor=west] at ( 1.1,-0.42) {$\underbrace{\hspace{17mm}}_{\text{2nd state}}$}; |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
329 |
\node [anchor=west] at (-1.5,0.65) {$\overbrace{\hspace{10mm}}^{\text{@{term Bk}-case}}$}; |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
330 |
\node [anchor=west] at (-0.1,0.65) {$\overbrace{\hspace{6mm}}^{\text{@{term Oc}-case}}$}; |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
331 |
\end{tikzpicture} |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
332 |
\label{dither} |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
333 |
\end{equation} |
29
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
334 |
|
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
335 |
\noindent |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
336 |
the reader can see we have organised our Turing machine programs so |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
337 |
that segments of two belong to a state. The first component of the |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
338 |
segment determines what action should be taken and which next state |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
339 |
should be transitioned to in case the head reads a @{term Bk}; |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
340 |
similarly the second component determines what should be done in |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
341 |
case of reading @{term Oc}. We have the convention that the first |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
342 |
state is always the \emph{starting state} of the Turing machine. |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
343 |
The @{text 0}-state is special in that it will be used as the |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
344 |
``halting state''. There are no instructions for the @{text |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
345 |
0}-state, but it will always perform a @{term Nop}-operation and |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
346 |
remain in the @{text 0}-state. Unlike Asperti and Riccioti |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
347 |
\cite{AspertiRicciotti12}, we have chosen a very concrete |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
348 |
representation for programs, because when constructing a universal |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
349 |
Turing machine, we need to define a coding function for programs. |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
350 |
This can be easily done for our programs-as-lists, but is more |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
351 |
difficult for the functions used by Asperti and Ricciotti. |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
352 |
|
29
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
353 |
Given a program @{term p}, a state |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
354 |
and the cell being read by the head, we need to fetch |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
355 |
the corresponding instruction from the program. For this we define |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
356 |
the function @{term fetch} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
357 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
358 |
\begin{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
359 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
360 |
\multicolumn{3}{l}{@{thm fetch.simps(1)[where b=DUMMY]}}\\ |
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
361 |
@{thm (lhs) fetch.simps(2)} & @{text "\<equiv>"} & @{text "case nth_of p (2 * s) of"}\\ |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
362 |
\multicolumn{3}{@ {\hspace{4cm}}l}{@{text "None \<Rightarrow> (Nop, 0) | Some i \<Rightarrow> i"}}\\ |
49
b388dceee892
shortening a bit the paper and updating various things
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
48
diff
changeset
|
363 |
@{thm (lhs) fetch.simps(3)} & @{text "\<equiv>"} & @{text "case nth_of p (2 * s + 1) of"}\\ |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
364 |
\multicolumn{3}{@ {\hspace{4cm}}l}{@{text "None \<Rightarrow> (Nop, 0) | Some i \<Rightarrow> i"}} |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
365 |
\end{tabular} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
366 |
\end{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
367 |
|
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
368 |
\noindent |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
369 |
In this definition the function @{term nth_of} returns the @{text n}th element |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
370 |
from a list, provided it exists (@{term Some}-case), or if it does not, it |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
371 |
returns the default action @{term Nop} and the default state @{text 0} |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
372 |
(@{term None}-case). In doing so we slightly deviate from the description |
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
373 |
in \cite{Boolos87}: if their Turing machines transition to a non-existing |
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
374 |
state, then the computation is halted. We will transition in such cases |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
375 |
to the @{text 0}-state.\footnote{\it However, with introducing the |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
376 |
notion of \emph{well-formed} Turing machine programs we will later exclude such |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
377 |
cases and make the @{text 0}-state the only ``halting state''. A program |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
378 |
@{term p} is said to be well-formed if it satisfies |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
379 |
the following three properties: |
33
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
380 |
|
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
381 |
\begin{center} |
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
382 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
383 |
@{term "t_correct p"} & @{text "\<equiv>"} & @{term "2 <= length p"}\\ |
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
384 |
& @{text "\<and>"} & @{term "iseven (length p)"}\\ |
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
385 |
& @{text "\<and>"} & @{term "\<forall> (a, s) \<in> set p. s <= length p div 2"} |
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
386 |
\end{tabular} |
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
387 |
\end{center} |
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
388 |
|
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
389 |
\noindent |
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
390 |
The first says that @{text p} must have at least an instruction for the starting |
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
391 |
state; the second that @{text p} has a @{term Bk} and @{term Oc} instruction for every |
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
392 |
state, and the third that every next-state is one of the states mentioned in |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
393 |
the program or being the @{text 0}-state. |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
394 |
} |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
395 |
|
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
396 |
A \emph{configuration} @{term c} of a Turing machine is a state together with |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
397 |
a tape. This is written as @{text "(s, (l, r))"}. If we have a |
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
398 |
configuration and a program, we can calculate |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
399 |
what the next configuration is by fetching the appropriate action and next state |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
400 |
from the program, and by updating the state and tape accordingly. |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
401 |
This single step of execution is defined as the function @{term tstep} |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
402 |
|
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
403 |
\begin{center} |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
404 |
\begin{tabular}{l} |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
405 |
@{text "step (s, (l, r)) p"} @{text "\<equiv>"}\\ |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
406 |
\hspace{10mm}@{text "let (a, s) = fetch p s (read r)"}\\ |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
407 |
\hspace{10mm}@{text "in (s', update (l, r) a)"} |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
408 |
\end{tabular} |
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
409 |
\end{center} |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
410 |
|
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
411 |
\noindent |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
412 |
where @{term "read r"} returns the head of the list @{text r}, or if @{text r} is |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
413 |
empty it returns @{term Bk}. |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
414 |
It is impossible in Isabelle/HOL to lift the @{term step}-function realising |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
415 |
a general evaluation function for Turing machines. The reason is that functions in HOL-based |
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
416 |
provers need to be terminating, and clearly there are Turing machine |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
417 |
programs that are not. We can however define an evaluation |
33
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
418 |
function so that it performs exactly @{text n} steps: |
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
419 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
420 |
\begin{center} |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
421 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
422 |
@{thm (lhs) steps.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) steps.simps(1)}\\ |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
423 |
@{thm (lhs) steps.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) steps.simps(2)}\\ |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
424 |
\end{tabular} |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
425 |
\end{center} |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
426 |
|
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
427 |
\noindent |
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
428 |
Recall our definition of @{term fetch} with the default value for |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
429 |
the @{text 0}-state. In case a Turing program takes in \cite{Boolos87} less |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
430 |
then @{text n} steps before it halts, then in our setting the @{term steps}-evaluation |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
431 |
does not actually halt, but rather transitions to the @{text 0}-state and |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
432 |
remains there performing @{text Nop}-actions until @{text n} is reached. |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
433 |
|
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
434 |
Given some input tape @{text "(l\<^isub>i,r\<^isub>i)"}, we can define when a program |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
435 |
@{term p} generates a specific output tape @{text "(l\<^isub>o,r\<^isub>o)"} |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
436 |
|
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
437 |
\begin{center} |
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
438 |
\begin{tabular}{l} |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
439 |
@{term "runs p (l\<^isub>i, r\<^isub>i) (l\<^isub>o,r\<^isub>o)"} @{text "\<equiv>"}\\ |
33
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
440 |
\hspace{6mm}@{text "\<exists>n. nsteps (1, (l\<^isub>i,r\<^isub>i)) p n = (0, (l\<^isub>o,r\<^isub>o))"} |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
441 |
\end{tabular} |
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
442 |
\end{center} |
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
443 |
|
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
444 |
\noindent |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
445 |
where @{text 1} stands for the starting state and @{text 0} for our final state. |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
446 |
A program @{text p} with input tape @{term "(l\<^isub>i, r\<^isub>i)"} \emph{halts} iff |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
447 |
|
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
448 |
\begin{center} |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
449 |
@{term "halts p (l\<^isub>i, r\<^isub>i) \<equiv> |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
450 |
\<exists>l\<^isub>o r\<^isub>o. runs p (l\<^isub>i, r\<^isub>i) (l\<^isub>o,r\<^isub>o)"} |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
451 |
\end{center} |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
452 |
|
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
453 |
\noindent |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
454 |
Later on we need to consider specific Turing machines that |
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
455 |
start with a tape in standard form and halt the computation |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
456 |
in standard form. To define a tape in standard form, it is |
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
457 |
useful to have an operation %@{ term "tape_of_nat_list DUMMY"} |
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
458 |
that translates lists of natural numbers into tapes. |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
459 |
|
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
460 |
|
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
461 |
\begin{center} |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
462 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
463 |
%@ { thm (lhs) tape_of_nat_list_def2(1)} & @{text "\<equiv>"} & @ { thm (rhs) tape_of_nat_list_def2(1)}\\ |
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
464 |
%@ { thm (lhs) tape_of_nat_list_def2(2)} & @{text "\<equiv>"} & @ { thm (rhs) tape_of_nat_list_def2(2)}\\ |
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
465 |
%@ { thm (lhs) tape_of_nat_list_def2(3)} & @{text "\<equiv>"} & @ { thm (rhs) tape_of_nat_list_def2(3)}\\ |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
466 |
\end{tabular} |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
467 |
\end{center} |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
468 |
|
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
469 |
|
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
470 |
|
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
471 |
|
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
472 |
By this we mean |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
473 |
|
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
474 |
\begin{center} |
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
475 |
%@ {thm haltP_def2[where p="p" and n="n", THEN eq_reflection]} |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
476 |
\end{center} |
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
477 |
|
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
478 |
\noindent |
33
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
479 |
This means the Turing machine starts with a tape containg @{text n} @{term Oc}s |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
480 |
and the head pointing to the first one; the Turing machine |
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
481 |
halts with a tape consisting of some @{term Bk}s, followed by a |
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
482 |
``cluster'' of @{term Oc}s and after that by some @{term Bk}s. |
33
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
483 |
The head in the output is pointing again at the first @{term Oc}. |
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
484 |
The intuitive meaning of this definition is to start the Turing machine with a |
32
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
485 |
tape corresponding to a value @{term n} and producing |
2557d2946354
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
31
diff
changeset
|
486 |
a new tape corresponding to the value @{term l} (the number of @{term Oc}s |
33
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
487 |
clustered on the output tape). |
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
488 |
|
284468a61346
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
32
diff
changeset
|
489 |
Before we can prove the undecidability of the halting problem for Turing machines, |
36
4b35e0e0784b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
35
diff
changeset
|
490 |
we have to define how to compose two Turing machines. Given our setup, this is |
37
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
491 |
relatively straightforward, if slightly fiddly. We use the following two |
36
4b35e0e0784b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
35
diff
changeset
|
492 |
auxiliary functions: |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
493 |
|
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
494 |
\begin{center} |
36
4b35e0e0784b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
35
diff
changeset
|
495 |
\begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1mm}}l@ {}} |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
496 |
@{thm (lhs) shift.simps} @{text "\<equiv>"} @{thm (rhs) shift.simps}\\ |
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
497 |
@{thm (lhs) adjust.simps} @{text "\<equiv>"} @{thm (rhs) adjust.simps}\\ |
36
4b35e0e0784b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
35
diff
changeset
|
498 |
\end{tabular} |
34
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
499 |
\end{center} |
22e5804b135c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
33
diff
changeset
|
500 |
|
36
4b35e0e0784b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
35
diff
changeset
|
501 |
\noindent |
37
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
502 |
The first adds @{text n} to all states, exept the @{text 0}-state, |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
503 |
thus moving all ``regular'' states to the segment starting at @{text |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
504 |
n}; the second adds @{term "length p div 2 + 1"} to the @{text |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
505 |
0}-state, thus ridirecting all references to the ``halting state'' |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
506 |
to the first state after the program @{text p}. With these two |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
507 |
functions in place, we can define the \emph{sequential composition} |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
508 |
of two Turing machine programs @{text "p\<^isub>1"} and @{text "p\<^isub>2"} |
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
509 |
|
36
4b35e0e0784b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
35
diff
changeset
|
510 |
\begin{center} |
50
816e84ca16d6
updated turing_basic by Jian
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
49
diff
changeset
|
511 |
@{thm tm_comp.simps[where ?p1.0="p\<^isub>1" and ?p2.0="p\<^isub>2", THEN eq_reflection]} |
36
4b35e0e0784b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
35
diff
changeset
|
512 |
\end{center} |
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
513 |
|
37
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
514 |
\noindent |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
515 |
This means @{text "p\<^isub>1"} is executed first. Whenever it originally |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
516 |
transitioned to the @{text 0}-state, it will in the composed program transition to the starting |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
517 |
state of @{text "p\<^isub>2"} instead. All the states of @{text "p\<^isub>2"} |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
518 |
have been shifted in order to make sure that the states of the composed |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
519 |
program @{text "p\<^isub>1 \<oplus> p\<^isub>2"} still only ``occupy'' |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
520 |
an initial segment of the natural numbers. |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
521 |
|
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
522 |
\begin{center} |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
523 |
\begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1mm}}p{6.9cm}@ {}} |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
524 |
@{thm (lhs) tcopy_def} & @{text "\<equiv>"} & @{thm (rhs) tcopy_def} |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
525 |
\end{tabular} |
c9b689bb4156
added new version of uncomputable
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
36
diff
changeset
|
526 |
\end{center} |
36
4b35e0e0784b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
35
diff
changeset
|
527 |
|
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
528 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
529 |
assertion holds for all tapes |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
530 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
531 |
Hoare rule for composition |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
532 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
533 |
For showing the undecidability of the halting problem, we need to consider |
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
534 |
two specific Turing machines. copying TM and dithering TM |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
535 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
536 |
correctness of the copying TM |
19
7971da47e8c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
18
diff
changeset
|
537 |
|
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
538 |
measure for the copying TM, which we however omit. |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
539 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
540 |
halting problem |
9
965df91a24bc
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
8
diff
changeset
|
541 |
*} |
965df91a24bc
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
8
diff
changeset
|
542 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
543 |
section {* Abacus Machines *} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
544 |
|
25
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
545 |
text {* |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
546 |
\noindent |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
547 |
Boolos et al \cite{Boolos87} use abacus machines as a |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
548 |
stepping stone for making it less laborious to write |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
549 |
programs for Turing machines. Abacus machines operate |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
550 |
over an unlimited number of registers $R_0$, $R_1$, \ldots |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
551 |
each being able to hold an arbitrary large natural number. |
27
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
552 |
We use natural numbers to refer to registers, but also |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
553 |
to refer to \emph{opcodes} of abacus |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
554 |
machines. Obcodes are given by the datatype |
25
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
555 |
|
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
556 |
\begin{center} |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
557 |
\begin{tabular}{rcll} |
27
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
558 |
@{text "o"} & $::=$ & @{term "Inc R\<iota>"} & increment register $R$ by one\\ |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
559 |
& $\mid$ & @{term "Dec R\<iota> o\<iota>"} & if content of $R$ is non-zero,\\ |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
560 |
& & & then decrement it by one\\ |
26
d3400d212091
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
25
diff
changeset
|
561 |
& & & otherwise jump to opcode $o$\\ |
27
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
562 |
& $\mid$ & @{term "Goto o\<iota>"} & jump to opcode $o$ |
25
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
563 |
\end{tabular} |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
564 |
\end{center} |
27
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
565 |
|
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
566 |
\noindent |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
567 |
A \emph{program} of an abacus machine is a list of such |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
568 |
obcodes. For example the program clearing the register |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
569 |
$R$ (setting it to 0) can be defined as follows: |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
570 |
|
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
571 |
\begin{center} |
48
559e5c6e5113
updated to ITP and updated directories
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
38
diff
changeset
|
572 |
%@ {thm clear.simps[where n="R\<iota>" and e="o\<iota>", THEN eq_reflection]} |
27
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
573 |
\end{center} |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
574 |
|
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
575 |
\noindent |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
576 |
The second opcode @{term "Goto 0"} in this programm means we |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
577 |
jump back to the first opcode, namely @{text "Dec R o"}. |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
578 |
The \emph{memory} $m$ of an abacus machine holding the values |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
579 |
of the registers is represented as a list of natural numbers. |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
580 |
We have a lookup function for this memory, written @{term "abc_lm_v m R\<iota>"}, |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
581 |
which looks up the content of register $R$; if $R$ |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
582 |
is not in this list, then we return 0. Similarly we |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
583 |
have a setting function, written @{term "abc_lm_s m R\<iota> n"}, which |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
584 |
sets the value of $R$ to $n$, and if $R$ was not yet in $m$ |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
585 |
it pads it approriately with 0s. |
29
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
586 |
|
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
587 |
|
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
588 |
Abacus machine halts when it jumps out of range. |
25
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
589 |
*} |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
590 |
|
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
591 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
592 |
section {* Recursive Functions *} |
7
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
593 |
|
13
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
594 |
section {* Wang Tiles\label{Wang} *} |
7
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
595 |
|
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
596 |
text {* |
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
597 |
Used in texture mapings - graphics |
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
598 |
*} |
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
599 |
|
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
600 |
|
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
601 |
section {* Related Work *} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
602 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
603 |
text {* |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
604 |
The most closely related work is by Norrish \cite{Norrish11}, and Asperti and |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
605 |
Ricciotti \cite{AspertiRicciotti12}. Norrish bases his approach on |
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
606 |
lambda-terms. For this he introduced a clever rewriting technology |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
607 |
based on combinators and de-Bruijn indices for |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
608 |
rewriting modulo $\beta$-equivalence (to keep it manageable) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
609 |
*} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
610 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
611 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
612 |
(* |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
613 |
Questions: |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
614 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
615 |
Can this be done: Ackerman function is not primitive |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
616 |
recursive (Nora Szasz) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
617 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
618 |
Tape is represented as two lists (finite - usually infinite tape)? |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
619 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
620 |
*) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
621 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
622 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
623 |
(*<*) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
624 |
end |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
625 |
(*>*) |