author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Fri, 11 Jan 2013 05:49:25 +0000 | |
changeset 31 | 4ef4b25e2997 |
parent 30 | ba789a0768a2 |
child 32 | 2557d2946354 |
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 |
|
25
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
6 |
hide_const (open) s |
18
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: |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
13 |
shows "fetch p 0 b == (Nop, 0)" |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
14 |
and "fetch p (Suc s) Bk == |
18
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))" |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
18 |
and "fetch p (Suc s) Oc == |
18
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))" |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
22 |
apply - |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
23 |
apply(rule_tac [!] eq_reflection) |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
24 |
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
|
25 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
26 |
lemma new_tape_def2: |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
27 |
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
|
28 |
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
|
29 |
and "new_tape L (l, r) == |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
30 |
(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
|
31 |
and "new_tape R (l, r) == |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
32 |
(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
|
33 |
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
|
34 |
apply - |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
35 |
apply(rule_tac [!] eq_reflection) |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
36 |
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
|
37 |
done |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
38 |
|
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
39 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
40 |
abbreviation |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
41 |
"read r == if (r = []) then Bk else hd r" |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
42 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
43 |
lemma tstep_def2: |
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
44 |
shows "tstep (s, l, r) p == (let (a, s') = fetch p s (read r) in (s', new_tape a (l, r)))" |
23
ea63068847aa
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
22
diff
changeset
|
45 |
apply - |
ea63068847aa
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
22
diff
changeset
|
46 |
apply(rule_tac [!] eq_reflection) |
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
47 |
by (auto split: if_splits prod.split list.split simp add: tstep.simps) |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
48 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
49 |
consts DUMMY::'a |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
50 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
51 |
notation (latex output) |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
52 |
Cons ("_::_" [78,77] 73) and |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
53 |
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
|
54 |
W1 ("W\<^bsub>\<^raw:\hspace{-2pt}>Oc\<^esub>") and |
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
55 |
tstep ("step") and |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
56 |
steps ("nsteps") and |
27
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
57 |
abc_lm_v ("lookup") and |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
58 |
abc_lm_s ("set") and |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
59 |
DUMMY ("\<^raw:\mbox{$\_$}>") |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
60 |
|
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
61 |
declare [[show_question_marks = false]] |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
62 |
(*>*) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
63 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
64 |
section {* Introduction *} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
65 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
66 |
text {* |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
67 |
|
8
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
68 |
\noindent |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
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
|
76 |
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
|
77 |
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
|
78 |
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
|
79 |
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
|
80 |
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
|
81 |
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
|
82 |
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
|
83 |
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
|
84 |
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
|
85 |
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
|
86 |
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
|
87 |
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
|
88 |
|
12
dd400b5797e1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
10
diff
changeset
|
89 |
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
|
90 |
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
|
91 |
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
|
92 |
$\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
|
93 |
of computability theory, |
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
94 |
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
|
95 |
formalisation is a clever infrastructure for reducing |
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
96 |
$\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
|
97 |
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
|
98 |
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
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
\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
|
103 |
|
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
104 |
\begin{quote} |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
105 |
\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
|
106 |
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
|
107 |
daunting prospect.'' |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
108 |
\end{quote} |
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
109 |
|
c216ae455c90
more on the paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
7
diff
changeset
|
110 |
\noindent |
13
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
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
|
117 |
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
|
118 |
with convenient reasoning infrastructures (for example induction |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
119 |
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
|
120 |
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
|
121 |
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
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
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
|
126 |
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
|
127 |
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
|
128 |
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
|
129 |
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
|
130 |
many proofs from the literature that use them. We will analyse one |
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
131 |
example---undecidability of Wang's tiling problem---in Section~\ref{Wang}. The |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
132 |
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
|
133 |
Turing machines}. |
12
dd400b5797e1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
10
diff
changeset
|
134 |
|
13
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
135 |
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
|
136 |
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
|
137 |
\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
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
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
|
142 |
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
|
143 |
\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
|
144 |
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
|
145 |
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
|
146 |
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
|
147 |
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
|
148 |
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
|
149 |
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
|
150 |
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
|
151 |
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
|
152 |
aspect that is completely left out from the informal description in |
31
4ef4b25e2997
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
30
diff
changeset
|
153 |
\cite{Boolos87}, and similar ones we are aware of, is arguments why certain Turing |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
154 |
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
|
155 |
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
|
156 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
157 |
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
|
158 |
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
|
159 |
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
|
160 |
23]{AspertiRicciotti12}: |
10
44e9d0c24fbc
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
9
diff
changeset
|
161 |
|
15
90bc8cccc218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
13
diff
changeset
|
162 |
\begin{quote}\it |
13
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
163 |
``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
|
164 |
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
|
165 |
annoying.'' |
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
166 |
\end{quote} |
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
167 |
|
15
90bc8cccc218
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
13
diff
changeset
|
168 |
\noindent |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
169 |
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
|
170 |
which goes back to Post \cite{Post36}, where all Turing machines |
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
171 |
operate on tapes that contain only \emph{blank} or \emph{occupied} cells |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
172 |
(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
|
173 |
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
|
174 |
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
|
175 |
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
|
176 |
the reasoning more uniform. In addition some proofs \emph{about} Turing |
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
177 |
machines will be simpler. The reason is that one often needs to encode |
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
178 |
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
|
179 |
functions are simpler too. Unfortunately, the restrictiveness also makes |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
180 |
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
|
181 |
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
|
182 |
\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
|
183 |
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
|
184 |
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
|
185 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
186 |
\smallskip |
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
187 |
\noindent |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
188 |
{\bf Contributions:} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
189 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
190 |
*} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
191 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
192 |
section {* Turing Machines *} |
9
965df91a24bc
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
8
diff
changeset
|
193 |
|
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
194 |
text {* \noindent |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
195 |
Turing machines can be thought of as having a read-write-unit, also |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
196 |
referred to as \emph{head}, |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
197 |
``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
|
198 |
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
|
199 |
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
|
200 |
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
|
201 |
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
|
202 |
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
|
203 |
head and @{term r} for the tape on the right-hand side. We have the |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
204 |
convention that the head, written @{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
|
205 |
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
|
206 |
be pictured as follows: |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
207 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
208 |
\begin{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
209 |
\begin{tikzpicture} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
210 |
\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
|
211 |
\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
|
212 |
\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
|
213 |
\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
|
214 |
\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
|
215 |
\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
|
216 |
\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
|
217 |
\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
|
218 |
\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
|
219 |
\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
|
220 |
\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
|
221 |
\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
|
222 |
\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
|
223 |
\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
|
224 |
\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
|
225 |
\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
|
226 |
\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
|
227 |
\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
|
228 |
\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
|
229 |
\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
|
230 |
\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
|
231 |
\end{tikzpicture} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
232 |
\end{center} |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
233 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
234 |
\noindent |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
235 |
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
|
236 |
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
|
237 |
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
|
238 |
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
|
239 |
the Turing machine can perform: |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
240 |
|
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
241 |
\begin{center} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
242 |
\begin{tabular}{rcll} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
243 |
@{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
|
244 |
& $\mid$ & @{term "W1"} & write occupied (@{term Oc})\\ |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
245 |
& $\mid$ & @{term L} & move left\\ |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
246 |
& $\mid$ & @{term R} & move right\\ |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
247 |
& $\mid$ & @{term Nop} & do-nothing operation\\ |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
248 |
\end{tabular} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
249 |
\end{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
250 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
251 |
\noindent |
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
252 |
We slightly deviate |
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
253 |
from the presentation in \cite{Boolos87} by using the @{term Nop} operation; however its use |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
254 |
will become important when we formalise universal Turing |
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
255 |
machines later. 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
|
256 |
following tape updating function: |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
257 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
258 |
\begin{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
259 |
\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
|
260 |
@{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
|
261 |
@{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
|
262 |
@{thm (lhs) new_tape_def2(3)} & @{text "\<equiv>"} & \\ |
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
263 |
\multicolumn{3}{l}{\hspace{1cm}@{thm (rhs) new_tape_def2(3)}}\\ |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
264 |
@{thm (lhs) new_tape_def2(4)} & @{text "\<equiv>"} & \\ |
20
ae3d568b887b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
19
diff
changeset
|
265 |
\multicolumn{3}{l}{\hspace{1cm}@{thm (rhs) new_tape_def2(4)}}\\ |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
266 |
@{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
|
267 |
\end{tabular} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
268 |
\end{center} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
269 |
|
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
270 |
\noindent |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
271 |
The first two clauses replace the head of the right-list |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
272 |
with a new @{term Bk} or @{term Oc}, repsectively. To see that |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
273 |
these two clauses make sense in case where @{text r} is the empty |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
274 |
list, one has to know that the tail function, @{term tl}, is in |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
275 |
Isabelle/HOL defined |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
276 |
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
|
277 |
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
|
278 |
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
|
279 |
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
|
280 |
head from the left-list and prepend it to the right-list. Similarly |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
281 |
in the clause for a right move action. The @{term Nop} operation |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
282 |
leaves the the tape unchanged. |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
283 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
284 |
Note that our treatment of the tape is rather ``unsymmetric''---we |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
285 |
have the convention that the head of the right-list is where the |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
286 |
head is currently positioned. Asperti and Ricciotti |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
287 |
\cite{AspertiRicciotti12} also consider such a representation, but |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
288 |
dismiss it as it complicates their definition for \emph{tape |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
289 |
equality}. The reason is that moving the head one step to |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
290 |
the left and then back to the right might change the tape (in case |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
291 |
of going over the ``edge''). Therefore they distinguish four types |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
292 |
of tapes: one where the tape is empty; another where the head |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
293 |
is on the left edge, respectively right edge, and in the middle |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
294 |
of the tape. The reading, writing and moving of the tape is then |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
295 |
defined in terms of these four cases. In this way they can keep the |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
296 |
tape in a ``normalised'' form, and thus making a left-move followed |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
297 |
by a right-move being the identity on tapes. Since we are not using |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
298 |
the notion of tape equality, we can get away with the unsymmetric |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
299 |
definition above, and by using the @{term update} function |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
300 |
cover uniformely all cases including corner cases. |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
301 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
302 |
Next we need to define the \emph{states} of a Turing machine. Given |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
303 |
how little is usually said about how to represent them in informal |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
304 |
presentations, it might be surprising that in a theorem prover we have |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
305 |
to select carfully a representation. If we use the naive representation |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
306 |
where a Turing machine consists of a finite set of states, then we |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
307 |
will have difficulties composing two Turing machines. In this case we |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
308 |
would need to combine two finite sets of states, possibly requiring |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
309 |
renaming states apart whenever both machines share states. This |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
310 |
renaming can be quite cumbersome to reason about. Therefore we made |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
311 |
the choice of representing a state by a natural number and the states |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
312 |
of a Turing machine will always consist of the initial segment |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
313 |
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
|
314 |
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
|
315 |
two Turing machine by ``shifting'' the states of one by an appropriate |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
316 |
amount to a higher segment and adjust some ``next states''. |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
317 |
|
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
318 |
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
|
319 |
an action and a natural number (the next state). A \emph{program} @{term p} of a Turing |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
320 |
machine is then a list of such pairs. Using the following Turing machine |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
321 |
program (consisting of four instructions) as an example |
29
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
322 |
|
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
323 |
\begin{center} |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
324 |
\begin{tikzpicture} |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
325 |
\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
|
326 |
\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
|
327 |
\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
|
328 |
\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
|
329 |
\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
|
330 |
\end{tikzpicture} |
29
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
331 |
\end{center} |
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
332 |
|
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
333 |
\noindent |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
334 |
the reader can see we have organised our Turing machine programs so |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
335 |
that segments of two belong to a state. The first component |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
336 |
of the segment determines what action should be taken and which next |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
337 |
state should be transitioned to in case the head read a @{term Bk}; |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
338 |
similarly the second component determines what should be done in |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
339 |
case of reading @{term Oc}. We have the convention that the |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
340 |
first state is always the \emph{starting state} of the Turing machine. |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
341 |
The 0-state is special in that it will be used as \emph{halting state}. |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
342 |
There are no instructions for the 0-state, but it will always |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
343 |
perform a @{term Nop}-operation and remain in the 0-state. |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
344 |
|
29
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
345 |
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
|
346 |
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
|
347 |
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
|
348 |
the function @{term fetch} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
349 |
|
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
350 |
\begin{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
351 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
352 |
\multicolumn{3}{l}{@{thm fetch_def2(1)[where b=DUMMY]}}\\ |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
353 |
@{thm (lhs) fetch_def2(2)} & @{text "\<equiv>"} & \\ |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
354 |
\multicolumn{3}{@ {\hspace{1cm}}l}{@{text "case nth_of p (2 * s) of"}}\\ |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
355 |
\multicolumn{3}{@ {\hspace{1.4cm}}l}{@{text "None \<Rightarrow> (Nop, 0) |"}}\\ |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
356 |
\multicolumn{3}{@ {\hspace{1.4cm}}l}{@{text "Some i \<Rightarrow> i"}}\\ |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
357 |
@{thm (lhs) fetch_def2(3)} & @{text "\<equiv>"} & \\ |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
358 |
\multicolumn{3}{@ {\hspace{1cm}}l}{@{text "case nth_of p (2 * s + 1) of"}}\\ |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
359 |
\multicolumn{3}{@ {\hspace{1.4cm}}l}{@{text "None \<Rightarrow> (Nop, 0) |"}}\\ |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
360 |
\multicolumn{3}{@ {\hspace{1.4cm}}l}{@{text "Some i \<Rightarrow> i"}} |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
361 |
\end{tabular} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
362 |
\end{center} |
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
363 |
|
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
364 |
\noindent |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
365 |
|
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
366 |
|
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
367 |
A \emph{configuration} @{term c} of a Turing machine is a state together with |
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
368 |
a tape. This is written as the triple @{term "(s, l, r)"}. If we have a |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
369 |
configuration and a program, we can calculate |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
370 |
what the next configuration is by fetching the appropriate next state |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
371 |
and action from the program. Such a single step of execution can be defined as |
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
372 |
|
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
373 |
\begin{center} |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
374 |
\begin{tabular}{l} |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
375 |
@{thm (lhs) tstep_def2(1)} @{text "\<equiv>"}\\ |
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
376 |
\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
|
377 |
\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
|
378 |
\end{tabular} |
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
379 |
\end{center} |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
380 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
381 |
No evaluator in HOL, because of totality. |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
382 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
383 |
\begin{center} |
30
ba789a0768a2
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
29
diff
changeset
|
384 |
\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
|
385 |
@{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
|
386 |
@{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
|
387 |
\end{tabular} |
22
cb8754a0568a
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
21
diff
changeset
|
388 |
\end{center} |
18
a961c2e4dcea
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
17
diff
changeset
|
389 |
|
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
390 |
\emph{well-formedness} of a Turing program |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
391 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
392 |
programs halts |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
393 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
394 |
shift and change of a p |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
395 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
396 |
composition of two ps |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
397 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
398 |
assertion holds for all tapes |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
399 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
400 |
Hoare rule for composition |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
401 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
402 |
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
|
403 |
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
|
404 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
405 |
correctness of the copying TM |
19
7971da47e8c4
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
18
diff
changeset
|
406 |
|
24
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
407 |
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
|
408 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
409 |
standard configuration |
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
410 |
|
9b4a739bff0f
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
23
diff
changeset
|
411 |
halting problem |
9
965df91a24bc
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
8
diff
changeset
|
412 |
*} |
965df91a24bc
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
8
diff
changeset
|
413 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
414 |
section {* Abacus Machines *} |
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
415 |
|
25
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
416 |
text {* |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
417 |
\noindent |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
418 |
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
|
419 |
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
|
420 |
programs for Turing machines. Abacus machines operate |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
421 |
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
|
422 |
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
|
423 |
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
|
424 |
to refer to \emph{opcodes} of abacus |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
425 |
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
|
426 |
|
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
427 |
\begin{center} |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
428 |
\begin{tabular}{rcll} |
27
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
429 |
@{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
|
430 |
& $\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
|
431 |
& & & then decrement it by one\\ |
26
d3400d212091
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
25
diff
changeset
|
432 |
& & & otherwise jump to opcode $o$\\ |
27
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
433 |
& $\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
|
434 |
\end{tabular} |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
435 |
\end{center} |
27
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
436 |
|
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
437 |
\noindent |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
438 |
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
|
439 |
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
|
440 |
$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
|
441 |
|
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
442 |
\begin{center} |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
443 |
@{thm clear.simps[where n="R\<iota>" and e="o\<iota>", THEN eq_reflection]} |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
444 |
\end{center} |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
445 |
|
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
446 |
\noindent |
a1e8b94d0b93
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
26
diff
changeset
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
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
|
452 |
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
|
453 |
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
|
454 |
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
|
455 |
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
|
456 |
it pads it approriately with 0s. |
29
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
457 |
|
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
458 |
|
1569a56bd81b
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
28
diff
changeset
|
459 |
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
|
460 |
*} |
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
461 |
|
8afe5bab4dee
update
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
24
diff
changeset
|
462 |
|
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
463 |
section {* Recursive Functions *} |
7
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
464 |
|
13
a7ec585d7f20
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
12
diff
changeset
|
465 |
section {* Wang Tiles\label{Wang} *} |
7
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
466 |
|
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
467 |
text {* |
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
468 |
Used in texture mapings - graphics |
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
469 |
*} |
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
470 |
|
f7896d90aa19
more
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
6
diff
changeset
|
471 |
|
6
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
472 |
section {* Related Work *} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
473 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
474 |
text {* |
17
66cebc19ef18
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
16
diff
changeset
|
475 |
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
|
476 |
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
|
477 |
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
|
478 |
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
|
479 |
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
|
480 |
*} |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
481 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
482 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
483 |
(* |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
484 |
Questions: |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
485 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
486 |
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
|
487 |
recursive (Nora Szasz) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
488 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
489 |
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
|
490 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
491 |
*) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
492 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
493 |
|
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
494 |
(*<*) |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
495 |
end |
50880fcda34d
added paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
496 |
(*>*) |