author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Thu, 10 Jan 2013 01:46:51 +0000 | |
changeset 18 | a961c2e4dcea |
parent 17 | 66cebc19ef18 |
child 19 | 7971da47e8c4 |
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 |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
imports UTM |
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 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
6 |
hide_const (open) s |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
7 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
8 |
abbreviation |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
9 |
"update p a == new_tape a p" |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
10 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
11 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
12 |
lemma fetch_def2: |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
13 |
shows "fetch p 0 b = (Nop, 0)" |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
14 |
and "fetch p (Suc s) Bk = |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
15 |
(case nth_of p (2 * s) of |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
16 |
Some i \<Rightarrow> i |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
17 |
| None \<Rightarrow> (Nop, 0))" |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
18 |
and "fetch p (Suc s) Oc = |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
19 |
(case nth_of p ((2 * s) + 1) of |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
20 |
Some i \<Rightarrow> i |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
21 |
| None \<Rightarrow> (Nop, 0))" |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
22 |
by (auto split: block.splits simp add: fetch.simps) |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
23 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
24 |
lemma new_tape_def2: |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
25 |
shows "new_tape W0 (l, r) == (l, Bk#(tl r))" |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
26 |
and "new_tape W1 (l, r) == (l, Oc#(tl r))" |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
27 |
and "new_tape L (l, r) == |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
28 |
(if l = [] then ([], Bk#r) else (tl l, (hd l) # r))" |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
29 |
and "new_tape R (l, r) == |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
30 |
(if r = [] then (Bk#l,[]) else ((hd r)#l, tl r))" |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
31 |
and "new_tape Nop (l, r) == (l, r)" |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
32 |
apply - |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
33 |
apply(rule_tac [!] eq_reflection) |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
34 |
apply(auto split: taction.splits simp add: new_tape.simps) |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
35 |
done |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
36 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
37 |
lemma tstep_def2: |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
38 |
shows "tstep (s, l, []) p = (let (ac, ns) = fetch p s Bk in (ns, new_tape ac (l, [])))" |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
39 |
and "tstep (s, l, x#xs) p = (let (ac, ns) = fetch p s x in (ns, new_tape ac (l, x#xs)))" |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
40 |
by (auto split: prod.split list.split simp add: tstep.simps) |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
41 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
42 |
consts DUMMY::'a |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
43 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
44 |
notation (latex output) |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
45 |
Cons ("_::_" [78,77] 73) and |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
46 |
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
|
47 |
W1 ("W\<^bsub>\<^raw:\hspace{-2pt}>Oc\<^esub>") and |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
48 |
DUMMY ("\<^raw:\mbox{$\_$}>") |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
49 |
|
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
50 |
declare [[show_question_marks = false]] |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
51 |
(*>*) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
52 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
53 |
section {* Introduction *} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
54 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
55 |
text {* |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
56 |
|
8
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
57 |
\noindent |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
58 |
We formalised in earlier work the correctness proofs for two |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
59 |
algorithms in Isabelle/HOL---one about type-checking in |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
60 |
LF~\cite{UrbanCheneyBerghofer11} and another about deciding requests |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
61 |
in access control~\cite{WuZhangUrban12}. The formalisations |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
62 |
uncovered a gap in the informal correctness proof of the former and |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
63 |
made us realise that important details were left out in the informal |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
64 |
model for the latter. However, in both cases we were unable to |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
65 |
formalise in Isabelle/HOL computability arguments about the |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
66 |
algorithms. The reason is that both algorithms are formulated in terms |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
67 |
of inductive predicates. Suppose @{text "P"} stands for one such |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
68 |
predicate. Decidability of @{text P} usually amounts to showing |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
69 |
whether \mbox{@{term "P \<or> \<not>P"}} holds. But this does \emph{not} work |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
70 |
in Isabelle/HOL, since it is a theorem prover based on classical logic |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
71 |
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
|
72 |
is always provable no matter whether @{text P} is constructed by |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
73 |
computable means. The same problem would arise if we had formulated |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
74 |
the algorithms as recursive functions, because internally in |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
75 |
Isabelle/HOL, like in all HOL-based theorem provers, functions are |
10
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
76 |
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
|
77 |
|
12
dd400b5797e1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
10
diff
changeset
|
78 |
The only satisfying way out of this problem in a theorem prover based on classical |
10
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
79 |
logic is to formalise a theory of computability. Norrish provided such |
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
80 |
a formalisation for the HOL4 theorem prover. He choose the |
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
81 |
$\lambda$-calculus as the starting point for his formalisation |
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
82 |
of computability theory, |
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
83 |
because of its ``simplicity'' \cite[Page 297]{Norrish11}. Part of his |
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
84 |
formalisation is a clever infrastructure for reducing |
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
85 |
$\lambda$-terms. He also established the computational equivalence |
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
86 |
between the $\lambda$-calculus and recursive functions. Nevertheless he |
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
87 |
concluded that it would be ``appealing'' to have formalisations for more |
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
88 |
operational models of computations, such as Turing machines or register |
12
dd400b5797e1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
10
diff
changeset
|
89 |
machines. One reason is that many proofs in the literature use |
10
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
90 |
them. He noted however that in the context of theorem provers |
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
91 |
\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
|
92 |
|
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
93 |
\begin{quote} |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
94 |
\it``If register machines are unappealing because of their |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
95 |
general fiddliness, Turing machines are an even more |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
96 |
daunting prospect.'' |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
97 |
\end{quote} |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
98 |
|
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
99 |
\noindent |
13
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
100 |
In this paper we took on this daunting prospect and provide a |
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
101 |
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
|
102 |
of register machines) and recursive functions. To see the difficulties |
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
103 |
involved with this work, one has to understand that interactive |
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
104 |
theorem provers, like Isabelle/HOL, are at their best when the |
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
105 |
data-structures at hand are ``structurally'' defined, like lists, |
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
106 |
natural numbers, regular expressions, etc. Such data-structures come |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
107 |
with convenient reasoning infrastructures (for example induction |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
108 |
principles, recursion combinators and so on). But this is \emph{not} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
109 |
the case with Turing machines (and also not with register machines): |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
110 |
underlying their definition is a set of states together with a |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
111 |
transition function, both of which are not structurally defined. This |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
112 |
means we have to implement our own reasoning infrastructure in order |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
113 |
to prove properties about them. This leads to annoyingly fiddly |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
114 |
formalisations. We noticed first the difference between both, |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
115 |
structural and non-structural, ``worlds'' when formalising the |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
116 |
Myhill-Nerode theorem, where regular expressions fared much better |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
117 |
than automata \cite{WuZhangUrban11}. However, with Turing machines |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
118 |
there seems to be no alternative if one wants to formalise the great |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
119 |
many proofs from the literature that use them. We will analyse one |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
120 |
example---undecidability of Wang tilings---in Section~\ref{Wang}. The |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
121 |
standard proof of this property uses the notion of \emph{universal |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
122 |
Turing machines}. |
12
dd400b5797e1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
10
diff
changeset
|
123 |
|
13
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
124 |
We are not the first who formalised Turing machines in a theorem |
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
125 |
prover: we are aware 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
|
126 |
\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
|
127 |
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
|
128 |
Turing machine. They report that the informal proofs from which they |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
129 |
started are not ``sufficiently accurate to be directly useable as a |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
130 |
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
|
131 |
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
|
132 |
\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
|
133 |
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
|
134 |
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
|
135 |
machines computing unary functions. We had to figure out a way to |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
136 |
generalize this result to $n$-ary functions. Similarly, when compiling |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
137 |
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
|
138 |
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
|
139 |
formalisation we need arbitrary functions. But the general ideas for |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
140 |
how to do this are clear enough in \cite{Boolos87}. However, one |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
141 |
aspect that is completely left out from the informal description in |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
142 |
\cite{Boolos87}, and similar ones we are aware of, are arguments why certain Turing |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
143 |
machines are correct. We will introduce Hoare-style proof rules |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
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 |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
160 |
operate on tapes that contain only \emph{blank} or \emph{filled} cells |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
161 |
(represented by @{term Bk} and @{term Oc}, respectively, in our |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
162 |
formalisation). 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
|
163 |
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
|
164 |
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
|
165 |
the reasoning more uniform. In addition some proofs \emph{about} Turing |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
166 |
machines will be simpler. The reason is that one often need to encode |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
167 |
Turing machines---if the Turing machines are simpler, then the coding |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
168 |
functions are simpler. Unfortunately, the restrictiveness also makes |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
169 |
it harder to design programs for these Turing machines. Therefore in order |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
170 |
to construct a \emph{universal Turing machine} we follow the proof in |
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 |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
173 |
machine can then be constructed as 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 |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
177 |
{\bf Contributions:} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
178 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
179 |
*} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
180 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
181 |
section {* Turing Machines *} |
9
965df91a24bc
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
8
diff
changeset
|
182 |
|
965df91a24bc
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
8
diff
changeset
|
183 |
text {* |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
184 |
\noindent |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
185 |
Turing machines can be thought of as having read-write-unit |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
186 |
``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
|
187 |
al~\cite{Boolos87} only consider tapes with cells being either blank |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
188 |
or occupied, which we represent with a datatype having two |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
189 |
constructors, namely @{text Bk} and @{text Oc}. One easy way to |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
190 |
represent such tapes is to use a pair of lists, written @{term "(l, |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
191 |
r)"}, where @{term l} stands for the tape on the left of the |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
192 |
read-write-unit and @{term r} for the tape on the right. We have the |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
193 |
convention that the head, written @{term hd}, of the right-list is |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
194 |
the cell on which the read-write-unit currently operates. This can |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
195 |
be pictured as follows: |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
196 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
197 |
\begin{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
198 |
\begin{tikzpicture} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
199 |
\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
|
200 |
\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
|
201 |
\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
|
202 |
\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
|
203 |
\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
|
204 |
\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
|
205 |
\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
|
206 |
\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
|
207 |
\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
|
208 |
\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
|
209 |
\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
|
210 |
\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
|
211 |
\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
|
212 |
\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
|
213 |
\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
|
214 |
\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
|
215 |
\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
|
216 |
\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
|
217 |
\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
|
218 |
\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
|
219 |
\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
|
220 |
\end{tikzpicture} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
221 |
\end{center} |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
222 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
223 |
\noindent |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
224 |
Note that by using lists each side of the tape is only finite. The |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
225 |
potential infinity is achieved by adding an appropriate blank cell |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
226 |
whenever the read-write unit goes over the ``edge'' of the tape. To |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
227 |
make this formal we define five possible \emph{actions} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
228 |
the Turing machine can perform: |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
229 |
|
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
230 |
\begin{center} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
231 |
\begin{tabular}{rcll} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
232 |
@{text "a"} & $::=$ & @{term "W0"} & write blank (@{term Bk})\\ |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
233 |
& $\mid$ & @{term "W1"} & write occupied (@{term Oc})\\ |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
234 |
& $\mid$ & @{term L} & move left\\ |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
235 |
& $\mid$ & @{term R} & move right\\ |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
236 |
& $\mid$ & @{term Nop} & do-nothing operation\\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
237 |
\end{tabular} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
238 |
\end{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
239 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
240 |
\noindent |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
241 |
By using the @{term Nop} operation, we slightly deviate |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
242 |
from the presentation in \cite{Boolos87}; however its use |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
243 |
will become important when we formalise universal Turing |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
244 |
machines. Given a tape and an action, we can define the |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
245 |
following updating function: |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
246 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
247 |
\begin{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
248 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
249 |
@{thm (lhs) new_tape_def2(1)} & @{text "\<equiv>"} & @{thm (rhs) new_tape_def2(1)}\\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
250 |
@{thm (lhs) new_tape_def2(2)} & @{text "\<equiv>"} & @{thm (rhs) new_tape_def2(2)}\\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
251 |
@{thm (lhs) new_tape_def2(3)} & @{text "\<equiv>"} & \\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
252 |
\multicolumn{3}{p{3cm}}{\hspace{1cm}@{thm (rhs) new_tape_def2(3)}}\\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
253 |
@{thm (lhs) new_tape_def2(4)} & @{text "\<equiv>"} & \\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
254 |
\multicolumn{3}{p{2cm}}{\hspace{1cm}@{thm (rhs) new_tape_def2(4)}}\\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
255 |
@{thm (lhs) new_tape_def2(5)} & @{text "\<equiv>"} & @{thm (rhs) new_tape_def2(5)}\\ |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
256 |
\end{tabular} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
257 |
\end{center} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
258 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
259 |
\noindent |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
260 |
The first two clauses replace the head of the right-list |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
261 |
with new @{term Bk} or @{term Oc}, repsectively. To see that |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
262 |
these clauses make sense in case where @{text r} is the empty |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
263 |
list, one has to know that the tail function, @{term tl}, is defined |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
264 |
such that @{term "tl [] == []"} holds. The third clause |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
265 |
implements the move of the read-write unit to the left: we need |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
266 |
to test if the left-list is empty; if yes, then we just add a |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
267 |
blank cell to the right-list; otherwise we have to remove the |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
268 |
head from the left-list and add it to the right-list. Similarly |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
269 |
in the clause for the right move. The @{term Nop} operation |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
270 |
leaves the the tape unchanged. |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
271 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
272 |
Note that our treatment of the tape is rather ``unsymmetric''---we |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
273 |
have the convention that the head of the right-list is where |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
274 |
the read-write unit is currently possitioned. Asperti and |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
275 |
Ricciotti \cite{AspertiRicciotti12} also consider such a |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
276 |
representation, but dismiss it as it complicates their |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
277 |
definition for \emph{tape equality}. The reason is that |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
278 |
moving the read-write unit to the left and then back |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
279 |
to the right can change the tape (in case of going |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
280 |
over the ``edge''). Therefore they distinguish four |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
281 |
cases where the tape is empty as well as the read-write unit |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
282 |
on the left edge, respectively right edge, or in the |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
283 |
middle. The reading and moving of the tape is then |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
284 |
defined in terms of these four cases. Since we are not |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
285 |
going to use the notion of tape equality, we can |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
286 |
get away with the definition above and be done with |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
287 |
all corner cases. |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
288 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
289 |
Next we need to define the \emph{states} of a Turing machine. Given |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
290 |
how little is usually said about how to represent states in informal |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
291 |
presentaions, it might be surprising that in a theorem prover we have |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
292 |
to select carfully a representation. If we use the naive representation |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
293 |
as a Turing machine consiting of a finite set of states, then we |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
294 |
will have difficulties composing two Turing machines. We would need |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
295 |
to somehow combine the two finite sets of states, possibly renaming |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
296 |
states apart if both machines share states. This renaming can be |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
297 |
quite cumbersome to reason about. Therefore we made the choice |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
298 |
of representing a state by a natural number and the states of a |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
299 |
Turing machine will always consist of the initial segment |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
300 |
of natural numbers starting from @{text 0} up to number of states |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
301 |
of the machine minus @{text 1}. In doing so we can compose |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
302 |
two Turing machine by ``shifting'' the states of one by an appropriate |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
303 |
amount to a higher segment. |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
304 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
305 |
An \emph{instruction} of a Turing machine is a pair consisting of a |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
306 |
natural number (the next state) and an action. A \emph{program} of a Turing |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
307 |
machine is then a list of such pairs. Given a program @{term p}, a state |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
308 |
and a cell being read by the read-write unnit, we need to fetch |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
309 |
the corresponding instruction in the program. For this we define |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
310 |
the function @{term fetch} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
311 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
312 |
\begin{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
313 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
314 |
@{thm (lhs) fetch_def2(1)[where b=DUMMY]} & @{text "\<equiv>"} & @{thm (rhs) fetch_def2(1)}\\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
315 |
@{thm (lhs) fetch_def2(2)} & @{text "\<equiv>"} & \\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
316 |
\multicolumn{3}{l}{\hspace{1cm}@{thm (rhs) fetch_def2(2)}}\\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
317 |
@{thm (lhs) fetch_def2(3)} & @{text "\<equiv>"} & \\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
318 |
\multicolumn{3}{l}{\hspace{1cm}@{thm (rhs) fetch_def2(3)}}\\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
319 |
\end{tabular} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
320 |
\end{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
321 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
322 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
323 |
For showing the undecidability of the halting problem, we need to consider |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
324 |
two specific Turing machines. |
10
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
325 |
|
9
965df91a24bc
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
8
diff
changeset
|
326 |
*} |
965df91a24bc
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
8
diff
changeset
|
327 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
328 |
section {* Abacus Machines *} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
329 |
|
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
330 |
section {* Recursive Functions *} |
7
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
331 |
|
13
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
332 |
section {* Wang Tiles\label{Wang} *} |
7
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
333 |
|
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
334 |
text {* |
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
335 |
Used in texture mapings - graphics |
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
336 |
*} |
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
337 |
|
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
338 |
|
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
339 |
section {* Related Work *} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
340 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
341 |
text {* |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
342 |
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
|
343 |
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
|
344 |
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
|
345 |
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
|
346 |
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
|
347 |
*} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
348 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
349 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
350 |
(* |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
351 |
Questions: |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
352 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
353 |
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
|
354 |
recursive (Nora Szasz) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
355 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
356 |
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
|
357 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
358 |
*) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
359 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
360 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
361 |
(*<*) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
362 |
end |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
363 |
(*>*) |