1 (* Title: Turing machine's definition and its charater |
|
2 Author: XuJian <xujian817@hotmail.com> |
|
3 Maintainer: Xujian |
|
4 *) |
|
5 |
|
6 header {* Undeciablity of the {\em Halting problem} *} |
|
7 |
|
8 theory uncomputable |
|
9 imports Main turing_basic |
|
10 begin |
|
11 |
|
12 text {* |
|
13 The {\em Copying} TM, which duplicates its input. |
|
14 *} |
|
15 definition tcopy :: "tprog" |
|
16 where |
|
17 "tcopy \<equiv> [(W0, 0), (R, 2), (R, 3), (R, 2), |
|
18 (W1, 3), (L, 4), (L, 4), (L, 5), (R, 11), (R, 6), |
|
19 (R, 7), (W0, 6), (R, 7), (R, 8), (W1, 9), (R, 8), |
|
20 (L, 10), (L, 9), (L, 10), (L, 5), (R, 12), (R, 12), |
|
21 (W1, 13), (L, 14), (R, 12), (R, 12), (L, 15), (W0, 14), |
|
22 (R, 0), (L, 15)]" |
|
23 |
|
24 text {* |
|
25 @{text "wipeLastBs tp"} removes all blanks at the end of tape @{text "tp"}. |
|
26 *} |
|
27 fun wipeLastBs :: "block list \<Rightarrow> block list" |
|
28 where |
|
29 "wipeLastBs bl = rev (dropWhile (\<lambda>a. a = Bk) (rev bl))" |
|
30 |
|
31 fun isBk :: "block \<Rightarrow> bool" |
|
32 where |
|
33 "isBk b = (b = Bk)" |
|
34 |
|
35 text {* |
|
36 The following functions are used to expression invariants of {\em Copying} TM. |
|
37 *} |
|
38 fun tcopy_F0 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
39 where |
|
40 "tcopy_F0 x (l, r) = (\<exists> i. l = Bk\<^bsup>i\<^esup> \<and> r = Oc\<^bsup>x\<^esup> @ Bk # Oc\<^bsup>x\<^esup>)" |
|
41 |
|
42 fun tcopy_F1 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
43 where |
|
44 "tcopy_F1 x (l, r) = (l = [] \<and> r = Oc\<^bsup>x\<^esup>)" |
|
45 |
|
46 fun tcopy_F2 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
47 where |
|
48 "tcopy_F2 x (l, r) = (\<exists> i j. i > 0 \<and> i + j = x \<and> l = Oc\<^bsup>i\<^esup> \<and> r = Oc\<^bsup>j\<^esup>)" |
|
49 |
|
50 fun tcopy_F3 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
51 where |
|
52 "tcopy_F3 x (l, r) = (x > 0 \<and> l = Bk # Oc\<^bsup>x\<^esup> \<and> tl r = [])" |
|
53 |
|
54 fun tcopy_F4 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
55 where |
|
56 "tcopy_F4 x (l, r) = (x > 0 \<and> ((l = Oc\<^bsup>x\<^esup> \<and> r = [Bk, Oc]) \<or> (l = Oc\<^bsup>x - 1\<^esup> \<and> r = [Oc, Bk, Oc])))" |
|
57 |
|
58 fun tcopy_F5_loop :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
59 where |
|
60 "tcopy_F5_loop x (l, r) = |
|
61 (\<exists> i j. i + j + 1 = x \<and> l = Oc\<^bsup>i\<^esup> \<and> r = Oc # Oc # Bk\<^bsup>j\<^esup> @ Oc\<^bsup>j\<^esup> \<and> j > 0)" |
|
62 |
|
63 fun tcopy_F5_exit :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
64 where |
|
65 "tcopy_F5_exit x (l, r) = |
|
66 (l = [] \<and> r = Bk # Oc # Bk\<^bsup>x\<^esup> @ Oc\<^bsup>x\<^esup> \<and> x > 0 )" |
|
67 |
|
68 fun tcopy_F5 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
69 where |
|
70 "tcopy_F5 x (l, r) = (tcopy_F5_loop x (l, r) \<or> tcopy_F5_exit x (l, r))" |
|
71 |
|
72 fun tcopy_F6 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
73 where |
|
74 "tcopy_F6 x (l, r) = |
|
75 (\<exists> i j any. i + j = x \<and> x > 0 \<and> i > 0 \<and> j > 0 \<and> l = Oc\<^bsup>i\<^esup> \<and> r = any#Bk\<^bsup>j\<^esup> @ Oc\<^bsup>j\<^esup>)" |
|
76 |
|
77 fun tcopy_F7 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
78 where |
|
79 "tcopy_F7 x (l, r) = |
|
80 (\<exists> i j k t. i + j = x \<and> i > 0 \<and> j > 0 \<and> k + t = Suc j \<and> l = Bk\<^bsup>k\<^esup> @ Oc\<^bsup>i\<^esup> \<and> r = Bk\<^bsup>t\<^esup> @ Oc\<^bsup>j\<^esup>)" |
|
81 |
|
82 fun tcopy_F8 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
83 where |
|
84 "tcopy_F8 x (l, r) = |
|
85 (\<exists> i j k t. i + j = x \<and> i > 0 \<and> j > 0 \<and> k + t = j \<and> l = Oc\<^bsup>k\<^esup> @ Bk\<^bsup>Suc j\<^esup> @ Oc\<^bsup>i\<^esup> \<and> r = Oc\<^bsup>t\<^esup>)" |
|
86 |
|
87 fun tcopy_F9_loop :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
88 where |
|
89 "tcopy_F9_loop x (l, r) = |
|
90 (\<exists> i j k t. i + j = Suc x \<and> i > 0 \<and> j > 0 \<and> k + t = j \<and> t > 0\<and> l = Oc\<^bsup>k\<^esup> @ Bk\<^bsup>j\<^esup> @ Oc\<^bsup>i\<^esup> \<and> r = Oc\<^bsup>t\<^esup>)" |
|
91 |
|
92 fun tcopy_F9_exit :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
93 where |
|
94 "tcopy_F9_exit x (l, r) = (\<exists> i j. i + j = Suc x \<and> i > 0 \<and> j > 0 \<and> l = Bk\<^bsup>j - 1\<^esup> @ Oc\<^bsup>i\<^esup> \<and> r = Bk # Oc\<^bsup>j\<^esup>)" |
|
95 |
|
96 fun tcopy_F9 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
97 where |
|
98 "tcopy_F9 x (l, r) = (tcopy_F9_loop x (l, r) \<or> |
|
99 tcopy_F9_exit x (l, r))" |
|
100 |
|
101 fun tcopy_F10_loop :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
102 where |
|
103 "tcopy_F10_loop x (l, r) = |
|
104 (\<exists> i j k t. i + j = Suc x \<and> i > 0 \<and> k + t + 1 = j \<and> l = Bk\<^bsup>k\<^esup> @ Oc\<^bsup>i\<^esup> \<and> r = Bk\<^bsup>Suc t\<^esup> @ Oc\<^bsup>j\<^esup>)" |
|
105 |
|
106 fun tcopy_F10_exit :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
107 where |
|
108 "tcopy_F10_exit x (l, r) = |
|
109 (\<exists> i j. i + j = x \<and> j > 0 \<and> l = Oc\<^bsup>i\<^esup> \<and> r = Oc # Bk\<^bsup>j\<^esup> @ Oc\<^bsup>j\<^esup>)" |
|
110 |
|
111 fun tcopy_F10 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
112 where |
|
113 "tcopy_F10 x (l, r) = (tcopy_F10_loop x (l, r) \<or> tcopy_F10_exit x (l, r))" |
|
114 |
|
115 fun tcopy_F11 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
116 where |
|
117 "tcopy_F11 x (l, r) = (x > 0 \<and> l = [Bk] \<and> r = Oc # Bk\<^bsup>x\<^esup> @ Oc\<^bsup>x\<^esup>)" |
|
118 |
|
119 fun tcopy_F12 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
120 where |
|
121 "tcopy_F12 x (l, r) = (\<exists> i j. i + j = Suc x \<and> x > 0 \<and> l = Oc\<^bsup>i\<^esup> @ [Bk] \<and> r = Bk\<^bsup>j\<^esup> @ Oc\<^bsup>x\<^esup>)" |
|
122 |
|
123 fun tcopy_F13 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
124 where |
|
125 "tcopy_F13 x (l, r) = |
|
126 (\<exists> i j. x > 0 \<and> i + j = x \<and> l = Oc\<^bsup>i\<^esup> @ [Bk] \<and> r = Oc # Bk\<^bsup>j\<^esup> @ Oc\<^bsup>x\<^esup> )" |
|
127 |
|
128 fun tcopy_F14 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
129 where |
|
130 "tcopy_F14 x (l, r) = (\<exists> any. x > 0 \<and> l = Oc\<^bsup>x\<^esup> @ [Bk] \<and> r = any#Oc\<^bsup>x\<^esup>)" |
|
131 |
|
132 fun tcopy_F15_loop :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
133 where |
|
134 "tcopy_F15_loop x (l, r) = |
|
135 (\<exists> i j. i + j = x \<and> x > 0 \<and> j > 0 \<and> l = Oc\<^bsup>i\<^esup> @ [Bk] \<and> r = Oc\<^bsup>j\<^esup> @ Bk # Oc\<^bsup>x\<^esup>)" |
|
136 |
|
137 fun tcopy_F15_exit :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
138 where |
|
139 "tcopy_F15_exit x (l, r) = (x > 0 \<and> l = [] \<and> r = Bk # Oc\<^bsup>x\<^esup> @ Bk # Oc\<^bsup>x\<^esup>)" |
|
140 |
|
141 fun tcopy_F15 :: "nat \<Rightarrow> tape \<Rightarrow> bool" |
|
142 where |
|
143 "tcopy_F15 x (l, r) = (tcopy_F15_loop x (l, r) \<or> tcopy_F15_exit x (l, r))" |
|
144 |
|
145 text {* |
|
146 The following @{text "inv_tcopy"} is the invariant of the {\em Copying} TM. |
|
147 *} |
|
148 fun inv_tcopy :: "nat \<Rightarrow> t_conf \<Rightarrow> bool" |
|
149 where |
|
150 "inv_tcopy x c = (let (state, tp) = c in |
|
151 if state = 0 then tcopy_F0 x tp |
|
152 else if state = 1 then tcopy_F1 x tp |
|
153 else if state = 2 then tcopy_F2 x tp |
|
154 else if state = 3 then tcopy_F3 x tp |
|
155 else if state = 4 then tcopy_F4 x tp |
|
156 else if state = 5 then tcopy_F5 x tp |
|
157 else if state = 6 then tcopy_F6 x tp |
|
158 else if state = 7 then tcopy_F7 x tp |
|
159 else if state = 8 then tcopy_F8 x tp |
|
160 else if state = 9 then tcopy_F9 x tp |
|
161 else if state = 10 then tcopy_F10 x tp |
|
162 else if state = 11 then tcopy_F11 x tp |
|
163 else if state = 12 then tcopy_F12 x tp |
|
164 else if state = 13 then tcopy_F13 x tp |
|
165 else if state = 14 then tcopy_F14 x tp |
|
166 else if state = 15 then tcopy_F15 x tp |
|
167 else False)" |
|
168 declare tcopy_F0.simps [simp del] |
|
169 tcopy_F1.simps [simp del] |
|
170 tcopy_F2.simps [simp del] |
|
171 tcopy_F3.simps [simp del] |
|
172 tcopy_F4.simps [simp del] |
|
173 tcopy_F5.simps [simp del] |
|
174 tcopy_F6.simps [simp del] |
|
175 tcopy_F7.simps [simp del] |
|
176 tcopy_F8.simps [simp del] |
|
177 tcopy_F9.simps [simp del] |
|
178 tcopy_F10.simps [simp del] |
|
179 tcopy_F11.simps [simp del] |
|
180 tcopy_F12.simps [simp del] |
|
181 tcopy_F13.simps [simp del] |
|
182 tcopy_F14.simps [simp del] |
|
183 tcopy_F15.simps [simp del] |
|
184 |
|
185 lemma exp_zero_simp: "(a\<^bsup>b\<^esup> = []) = (b = 0)" |
|
186 apply(auto simp: exponent_def) |
|
187 done |
|
188 |
|
189 lemma exp_zero_simp2: "([] = a\<^bsup>b\<^esup> ) = (b = 0)" |
|
190 apply(auto simp: exponent_def) |
|
191 done |
|
192 |
|
193 lemma [elim]: "\<lbrakk>tstep (0, a, b) tcopy = (s, l, r); s \<noteq> 0\<rbrakk> \<Longrightarrow> RR" |
|
194 apply(simp add: tstep.simps tcopy_def fetch.simps) |
|
195 done |
|
196 |
|
197 lemma [elim]: "\<lbrakk>tstep (Suc 0, a, b) tcopy = (s, l, r); s \<noteq> 0; s \<noteq> 2\<rbrakk> |
|
198 \<Longrightarrow> RR" |
|
199 apply(simp add: tstep.simps tcopy_def fetch.simps) |
|
200 apply(simp split: block.splits list.splits) |
|
201 done |
|
202 |
|
203 lemma [elim]: "\<lbrakk>tstep (2, a, b) tcopy = (s, l, r); s \<noteq> 2; s \<noteq> 3\<rbrakk> |
|
204 \<Longrightarrow> RR" |
|
205 apply(simp add: tstep.simps tcopy_def fetch.simps) |
|
206 apply(simp split: block.splits list.splits) |
|
207 done |
|
208 |
|
209 lemma [elim]: "\<lbrakk>tstep (3, a, b) tcopy = (s, l, r); s \<noteq> 3; s \<noteq> 4\<rbrakk> |
|
210 \<Longrightarrow> RR" |
|
211 by(simp add: tstep.simps tcopy_def fetch.simps |
|
212 split: block.splits list.splits) |
|
213 |
|
214 lemma [elim]: "\<lbrakk>tstep (4, a, b) tcopy = (s, l, r); s \<noteq> 4; s \<noteq> 5\<rbrakk> |
|
215 \<Longrightarrow> RR" |
|
216 by(simp add: tstep.simps tcopy_def fetch.simps |
|
217 split: block.splits list.splits) |
|
218 |
|
219 lemma [elim]: "\<lbrakk>tstep (5, a, b) tcopy = (s, l, r); s \<noteq> 6; s \<noteq> 11\<rbrakk> |
|
220 \<Longrightarrow> RR" |
|
221 by(simp add: tstep.simps tcopy_def fetch.simps |
|
222 split: block.splits list.splits) |
|
223 |
|
224 lemma [elim]: "\<lbrakk>tstep (6, a, b) tcopy = (s, l, r); s \<noteq> 6; s \<noteq> 7\<rbrakk> |
|
225 \<Longrightarrow> RR" |
|
226 by(simp add: tstep.simps tcopy_def fetch.simps |
|
227 split: block.splits list.splits) |
|
228 |
|
229 lemma [elim]: "\<lbrakk>tstep (7, a, b) tcopy = (s, l, r); s \<noteq> 7; s \<noteq> 8\<rbrakk> |
|
230 \<Longrightarrow> RR" |
|
231 by(simp add: tstep.simps tcopy_def fetch.simps |
|
232 split: block.splits list.splits) |
|
233 |
|
234 lemma [elim]: "\<lbrakk>tstep (8, a, b) tcopy = (s, l, r); s \<noteq> 8; s \<noteq> 9\<rbrakk> |
|
235 \<Longrightarrow> RR" |
|
236 by(simp add: tstep.simps tcopy_def fetch.simps |
|
237 split: block.splits list.splits) |
|
238 |
|
239 lemma [elim]: "\<lbrakk>tstep (9, a, b) tcopy = (s, l, r); s \<noteq> 9; s \<noteq> 10\<rbrakk> |
|
240 \<Longrightarrow> RR" |
|
241 by(simp add: tstep.simps tcopy_def fetch.simps |
|
242 split: block.splits list.splits) |
|
243 |
|
244 lemma [elim]: "\<lbrakk>tstep (10, a, b) tcopy = (s, l, r); s \<noteq> 10; s \<noteq> 5\<rbrakk> |
|
245 \<Longrightarrow> RR" |
|
246 by(simp add: tstep.simps tcopy_def fetch.simps |
|
247 split: block.splits list.splits) |
|
248 |
|
249 lemma [elim]: "\<lbrakk>tstep (11, a, b) tcopy = (s, l, r); s \<noteq> 12\<rbrakk> \<Longrightarrow> RR" |
|
250 by(simp add: tstep.simps tcopy_def fetch.simps |
|
251 split: block.splits list.splits) |
|
252 |
|
253 lemma [elim]: "\<lbrakk>tstep (12, a, b) tcopy = (s, l, r); s \<noteq> 13; s \<noteq> 14\<rbrakk> |
|
254 \<Longrightarrow> RR" |
|
255 by(simp add: tstep.simps tcopy_def fetch.simps |
|
256 split: block.splits list.splits) |
|
257 |
|
258 lemma [elim]: "\<lbrakk>tstep (13, a, b) tcopy = (s, l, r); s \<noteq> 12\<rbrakk> \<Longrightarrow> RR" |
|
259 by(simp add: tstep.simps tcopy_def fetch.simps |
|
260 split: block.splits list.splits) |
|
261 |
|
262 lemma [elim]: "\<lbrakk>tstep (14, a, b) tcopy = (s, l, r); s \<noteq> 14; s \<noteq> 15\<rbrakk> |
|
263 \<Longrightarrow> RR" |
|
264 by(simp add: tstep.simps tcopy_def fetch.simps |
|
265 split: block.splits list.splits) |
|
266 |
|
267 lemma [elim]: "\<lbrakk>tstep (15, a, b) tcopy = (s, l, r); s \<noteq> 0; s \<noteq> 15\<rbrakk> |
|
268 \<Longrightarrow> RR" |
|
269 by(simp add: tstep.simps tcopy_def fetch.simps |
|
270 split: block.splits list.splits) |
|
271 |
|
272 (* |
|
273 lemma min_Suc4: "min (Suc (Suc x)) x = x" |
|
274 by auto |
|
275 |
|
276 lemma takeWhile2replicate: |
|
277 "\<exists>n. takeWhile (\<lambda>a. a = b) list = replicate n b" |
|
278 apply(induct list) |
|
279 apply(rule_tac x = 0 in exI, simp) |
|
280 apply(auto) |
|
281 apply(rule_tac x = "Suc n" in exI, simp) |
|
282 done |
|
283 |
|
284 lemma rev_replicate_same: "rev (replicate x b) = replicate x b" |
|
285 by(simp) |
|
286 |
|
287 lemma rev_equal: "a = b \<Longrightarrow> rev a = rev b" |
|
288 by simp |
|
289 |
|
290 lemma rev_equal_rev: "rev a = rev b \<Longrightarrow> a = b" |
|
291 by simp |
|
292 |
|
293 lemma rep_suc_rev[simp]:"replicate n b @ [b] = replicate (Suc n) b" |
|
294 apply(rule rev_equal_rev) |
|
295 apply(simp only: rev_append rev_replicate_same) |
|
296 apply(auto) |
|
297 done |
|
298 |
|
299 lemma replicate_Cons_simp: "b # replicate n b @ xs = |
|
300 replicate n b @ b # xs" |
|
301 apply(simp) |
|
302 done |
|
303 *) |
|
304 |
|
305 lemma [elim]: "\<lbrakk>tstep (14, b, c) tcopy = (15, ab, ba); |
|
306 tcopy_F14 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F15 x (ab, ba)" |
|
307 apply(auto simp: tstep.simps tcopy_def |
|
308 tcopy_F14.simps tcopy_F15.simps fetch.simps new_tape.simps |
|
309 split: if_splits list.splits block.splits) |
|
310 apply(erule_tac [!] x = "x - 1" in allE) |
|
311 apply(case_tac [!] x, simp_all add: exp_ind_def exp_zero) |
|
312 apply(erule_tac [!] x = "Suc 0" in allE, simp_all) |
|
313 done |
|
314 |
|
315 (* |
|
316 lemma dropWhile_drophd: "\<not> p a \<Longrightarrow> |
|
317 (dropWhile p xs @ (a # as)) = (dropWhile p (xs @ [a]) @ as)" |
|
318 apply(induct xs) |
|
319 apply(auto) |
|
320 done |
|
321 *) |
|
322 (* |
|
323 lemma dropWhile_append3: "\<lbrakk>\<not> p a; |
|
324 listall ((dropWhile p xs) @ [a]) isBk\<rbrakk> \<Longrightarrow> |
|
325 listall (dropWhile p (xs @ [a])) isBk" |
|
326 apply(drule_tac p = p and xs = xs and a = a in dropWhile_drophd, simp) |
|
327 done |
|
328 |
|
329 lemma takeWhile_append3: "\<lbrakk>\<not>p a; (takeWhile p xs) = b\<rbrakk> |
|
330 \<Longrightarrow> takeWhile p (xs @ (a # as)) = b" |
|
331 apply(drule_tac P = p and xs = xs and x = a and l = as in |
|
332 takeWhile_tail) |
|
333 apply(simp) |
|
334 done |
|
335 |
|
336 lemma listall_append: "list_all p (xs @ ys) = |
|
337 (list_all p xs \<and> list_all p ys)" |
|
338 apply(induct xs) |
|
339 apply(simp+) |
|
340 done |
|
341 *) |
|
342 lemma false_case1: |
|
343 "\<lbrakk>Oc\<^bsup>j\<^esup> @ Bk # Oc\<^bsup>i + j\<^esup> = Oc # list; |
|
344 0 < i; |
|
345 \<forall>ia. tl (Oc\<^bsup>i\<^esup> @ [Bk]) = Oc\<^bsup>ia\<^esup> @ [Bk] \<longrightarrow> (\<forall>ja. ia + ja = i + j |
|
346 \<longrightarrow> hd (Oc\<^bsup>i\<^esup> @ [Bk]) # Oc # list \<noteq> Oc\<^bsup>ja\<^esup> @ Bk # Oc\<^bsup>i + j\<^esup>)\<rbrakk> |
|
347 \<Longrightarrow> RR" |
|
348 apply(case_tac i, auto simp: exp_ind_def) |
|
349 apply(erule_tac x = nat in allE, simp add:exp_ind_def) |
|
350 apply(erule_tac x = "Suc j" in allE, simp) |
|
351 done |
|
352 |
|
353 lemma false_case3:"\<forall>ja. ja \<noteq> i \<Longrightarrow> RR" |
|
354 by auto |
|
355 |
|
356 lemma [elim]: "\<lbrakk>tstep (15, b, c) tcopy = (15, ab, ba); |
|
357 tcopy_F15 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F15 x (ab, ba)" |
|
358 apply(auto simp: tstep.simps tcopy_F15.simps |
|
359 tcopy_def fetch.simps new_tape.simps |
|
360 split: if_splits list.splits block.splits elim: false_case1) |
|
361 apply(case_tac [!] i, simp_all add: exp_zero exp_ind_def) |
|
362 apply(erule_tac [!] x = nat in allE, simp_all add: exp_ind_def) |
|
363 apply(auto elim: false_case3) |
|
364 done |
|
365 |
|
366 lemma [elim]: "\<lbrakk>tstep (14, b, c) tcopy = (14, ab, ba); |
|
367 tcopy_F14 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F14 x (ab, ba)" |
|
368 apply(auto simp: tcopy_F14.simps tcopy_def tstep.simps |
|
369 tcopy_F14.simps fetch.simps new_tape.simps |
|
370 split: if_splits list.splits block.splits) |
|
371 done |
|
372 |
|
373 |
|
374 lemma [elim]: "\<lbrakk>tstep (12, b, c) tcopy = (14, ab, ba); |
|
375 tcopy_F12 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F14 x (ab, ba)" |
|
376 apply(auto simp:tcopy_F12.simps tcopy_F14.simps |
|
377 tcopy_def tstep.simps fetch.simps new_tape.simps |
|
378 split: if_splits list.splits block.splits) |
|
379 apply(case_tac [!] j, simp_all add: exp_zero exp_ind_def) |
|
380 done |
|
381 |
|
382 lemma [elim]: "\<lbrakk>tstep (12, b, c) tcopy = (13, ab, ba); |
|
383 tcopy_F12 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F13 x (ab, ba)" |
|
384 apply(auto simp:tcopy_F12.simps tcopy_F13.simps |
|
385 tcopy_def tstep.simps fetch.simps new_tape.simps |
|
386 split: if_splits list.splits block.splits) |
|
387 apply(case_tac x, simp_all add: exp_ind_def exp_zero) |
|
388 apply(rule_tac [!] x = i in exI, simp_all) |
|
389 apply(rule_tac [!] x = "j - 1" in exI) |
|
390 apply(case_tac [!] j, simp_all add: exp_ind_def exp_zero) |
|
391 apply(case_tac x, simp_all add: exp_ind_def exp_zero) |
|
392 done |
|
393 |
|
394 lemma [elim]: "\<lbrakk>tstep (11, b, c) tcopy = (12, ab, ba); |
|
395 tcopy_F11 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F12 x (ab, ba)" |
|
396 apply(simp_all add:tcopy_F12.simps tcopy_F11.simps |
|
397 tcopy_def tstep.simps fetch.simps new_tape.simps) |
|
398 apply(auto) |
|
399 apply(rule_tac x = "Suc 0" in exI, |
|
400 rule_tac x = x in exI, simp add: exp_ind_def exp_zero) |
|
401 done |
|
402 |
|
403 |
|
404 lemma [elim]: "\<lbrakk>tstep (13, b, c) tcopy = (12, ab, ba); |
|
405 tcopy_F13 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F12 x (ab, ba)" |
|
406 apply(auto simp:tcopy_F12.simps tcopy_F13.simps |
|
407 tcopy_def tstep.simps fetch.simps new_tape.simps |
|
408 split: if_splits list.splits block.splits) |
|
409 apply(rule_tac [!] x = "Suc i" in exI, simp_all add: exp_ind_def) |
|
410 done |
|
411 |
|
412 lemma [elim]: "\<lbrakk>tstep (5, b, c) tcopy = (11, ab, ba); |
|
413 tcopy_F5 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F11 x (ab, ba)" |
|
414 apply(simp_all add:tcopy_F11.simps tcopy_F5.simps tcopy_def |
|
415 tstep.simps fetch.simps new_tape.simps) |
|
416 apply(simp split: if_splits list.splits block.splits) |
|
417 done |
|
418 |
|
419 lemma F10_false: "tcopy_F10 x (b, []) = False" |
|
420 apply(auto simp: tcopy_F10.simps exp_ind_def) |
|
421 done |
|
422 |
|
423 lemma F10_false2: "tcopy_F10 x ([], Bk # list) = False" |
|
424 apply(auto simp:tcopy_F10.simps) |
|
425 apply(case_tac i, simp_all add: exp_ind_def exp_zero) |
|
426 done |
|
427 |
|
428 lemma [simp]: "tcopy_F10_exit x (b, Bk # list) = False" |
|
429 apply(auto simp: tcopy_F10.simps) |
|
430 done |
|
431 |
|
432 declare tcopy_F10_loop.simps[simp del] tcopy_F10_exit.simps[simp del] |
|
433 |
|
434 lemma [simp]: "tcopy_F10_loop x (b, [Bk]) = False" |
|
435 apply(auto simp: tcopy_F10_loop.simps) |
|
436 apply(simp add: exp_ind_def) |
|
437 done |
|
438 |
|
439 lemma [elim]: "\<lbrakk>tstep (10, b, c) tcopy = (10, ab, ba); |
|
440 tcopy_F10 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F10 x (ab, ba)" |
|
441 apply(simp add: tcopy_def tstep.simps fetch.simps |
|
442 new_tape.simps exp_ind_def exp_zero_simp exp_zero_simp2 F10_false F10_false2 |
|
443 split: if_splits list.splits block.splits) |
|
444 apply(simp add: tcopy_F10.simps del: tcopy_F10_loop.simps tcopy_F10_exit.simps) |
|
445 apply(case_tac b, simp, case_tac aa) |
|
446 apply(rule_tac disjI1) |
|
447 apply(simp only: tcopy_F10_loop.simps) |
|
448 apply(erule_tac exE)+ |
|
449 apply(rule_tac x = i in exI, rule_tac x = j in exI, |
|
450 rule_tac x = "k - 1" in exI, rule_tac x = "Suc t" in exI, simp) |
|
451 apply(case_tac k, simp_all add: exp_ind_def exp_zero) |
|
452 apply(case_tac i, simp_all add: exp_ind_def exp_zero) |
|
453 apply(rule_tac disjI2) |
|
454 apply(simp only: tcopy_F10_loop.simps tcopy_F10_exit.simps) |
|
455 apply(erule_tac exE)+ |
|
456 apply(rule_tac x = "i - 1" in exI, rule_tac x = "j" in exI) |
|
457 apply(case_tac k, simp_all add: exp_ind_def exp_zero) |
|
458 apply(case_tac i, simp_all add: exp_ind_def exp_zero) |
|
459 apply(auto) |
|
460 apply(simp add: exp_ind_def) |
|
461 done |
|
462 |
|
463 (* |
|
464 lemma false_case4: "\<lbrakk>i + (k + t) = Suc x; |
|
465 0 < i; |
|
466 Bk # list = Oc\<^bsup>t\<^esup>; |
|
467 \<forall>ia j. ia + j = Suc x \<longrightarrow> ia = 0 \<or> (\<forall>ka. tl (Oc\<^bsup>k\<^esup>) @ Bk\<^bsup>k + t\<^esup> @ Oc\<^bsup>i\<^esup> = Bk\<^bsup>ka\<^esup> @ Oc\<^bsup>ia\<^esup> \<longrightarrow> (\<forall>ta. Suc (ka + ta) = j \<longrightarrow> Oc # Oc\<^bsup>t\<^esup> \<noteq> Bk\<^bsup>Suc ta\<^esup> @ Oc\<^bsup>j\<^esup>)); |
|
468 0 < k\<rbrakk> |
|
469 \<Longrightarrow> RR" |
|
470 apply(case_tac t, simp_all add: exp_ind_def exp_zero) |
|
471 done |
|
472 |
|
473 lemma false_case5: " |
|
474 \<lbrakk>Suc (i + nata) = x; |
|
475 0 < i; |
|
476 \<forall>ia j. ia + j = Suc x \<longrightarrow> ia = 0 \<or> (\<forall>k. Bk\<^bsup>nata\<^esup> @ Oc\<^bsup>i\<^esup> = Bk\<^bsup>k\<^esup> @ Oc\<^bsup>ia\<^esup> \<longrightarrow> (\<forall>t. Suc (k + t) = j \<longrightarrow> Bk # Oc # Oc # Oc\<^bsup>nata\<^esup> \<noteq> Bk\<^bsup>t\<^esup> @ Oc\<^bsup>j\<^esup>))\<rbrakk> |
|
477 \<Longrightarrow> False" |
|
478 apply(erule_tac x = i in allE, simp) |
|
479 apply(erule_tac x = "Suc (Suc nata)" in allE, simp) |
|
480 apply(erule_tac x = nata in allE, simp, simp add: exp_ind_def exp_zero) |
|
481 done |
|
482 |
|
483 lemma false_case6: "\<lbrakk>0 < x; \<forall>i. tl (Oc\<^bsup>x\<^esup>) = Oc\<^bsup>i\<^esup> \<longrightarrow> (\<forall>j. i + j = x \<longrightarrow> j = 0 \<or> [Bk, Oc] \<noteq> Bk\<^bsup>j\<^esup> @ Oc\<^bsup>j\<^esup>)\<rbrakk> |
|
484 \<Longrightarrow> False" |
|
485 apply(erule_tac x = "x - 1" in allE) |
|
486 apply(case_tac x, simp_all add: exp_ind_def exp_zero) |
|
487 apply(erule_tac x = "Suc 0" in allE, simp) |
|
488 done |
|
489 *) |
|
490 |
|
491 lemma [simp]: "tcopy_F9 x ([], b) = False" |
|
492 apply(auto simp: tcopy_F9.simps) |
|
493 apply(case_tac [!] i, simp_all add: exp_ind_def exp_zero) |
|
494 done |
|
495 |
|
496 lemma [simp]: "tcopy_F9 x (b, []) = False" |
|
497 apply(auto simp: tcopy_F9.simps) |
|
498 apply(case_tac [!] t, simp_all add: exp_ind_def exp_zero) |
|
499 done |
|
500 |
|
501 declare tcopy_F9_loop.simps[simp del] tcopy_F9_exit.simps[simp del] |
|
502 lemma [simp]: "tcopy_F9_loop x (b, Bk # list) = False" |
|
503 apply(auto simp: tcopy_F9_loop.simps) |
|
504 apply(case_tac [!] t, simp_all add: exp_ind_def exp_zero) |
|
505 done |
|
506 |
|
507 lemma [elim]: "\<lbrakk>tstep (9, b, c) tcopy = (10, ab, ba); |
|
508 tcopy_F9 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F10 x (ab, ba)" |
|
509 apply(auto simp:tcopy_def |
|
510 tstep.simps fetch.simps new_tape.simps exp_zero_simp |
|
511 exp_zero_simp2 |
|
512 split: if_splits list.splits block.splits) |
|
513 apply(case_tac "hd b", simp add:tcopy_F9.simps tcopy_F10.simps ) |
|
514 apply(simp only: tcopy_F9_exit.simps tcopy_F10_loop.simps) |
|
515 apply(erule_tac exE)+ |
|
516 apply(rule_tac x = i in exI, rule_tac x = j in exI, simp) |
|
517 apply(rule_tac x = "j - 2" in exI, simp add: exp_ind_def) |
|
518 apply(case_tac j, simp, simp) |
|
519 apply(case_tac nat, simp_all add: exp_zero exp_ind_def) |
|
520 apply(case_tac x, simp_all add: exp_ind_def exp_zero) |
|
521 apply(simp add: tcopy_F9.simps tcopy_F10.simps) |
|
522 apply(rule_tac disjI2) |
|
523 apply(simp only: tcopy_F10_exit.simps tcopy_F9_exit.simps) |
|
524 apply(erule_tac exE)+ |
|
525 apply(simp) |
|
526 apply(case_tac j, simp_all, case_tac nat, simp_all add: exp_ind_def exp_zero) |
|
527 apply(case_tac x, simp_all add: exp_ind_def exp_zero) |
|
528 apply(rule_tac x = nata in exI, rule_tac x = 1 in exI, simp add: exp_ind_def exp_zero) |
|
529 done |
|
530 |
|
531 lemma false_case7: |
|
532 "\<lbrakk>i + (n + t) = x; 0 < i; 0 < t; Oc # list = Oc\<^bsup>t\<^esup>; k = Suc n; |
|
533 \<forall>j. i + j = Suc x \<longrightarrow> (\<forall>k. Oc\<^bsup>n\<^esup> @ Bk # Bk\<^bsup>n + t\<^esup> = Oc\<^bsup>k\<^esup> @ Bk\<^bsup>j\<^esup> \<longrightarrow> |
|
534 (\<forall>ta. k + ta = j \<longrightarrow> ta = 0 \<or> Oc # Oc\<^bsup>t\<^esup> \<noteq> Oc\<^bsup>ta\<^esup>))\<rbrakk> |
|
535 \<Longrightarrow> RR" |
|
536 apply(erule_tac x = "k + t" in allE, simp) |
|
537 apply(erule_tac x = n in allE, simp add: exp_ind_def) |
|
538 apply(erule_tac x = "Suc t" in allE, simp) |
|
539 done |
|
540 |
|
541 lemma false_case8: |
|
542 "\<lbrakk>i + t = Suc x; |
|
543 0 < i; |
|
544 0 < t; |
|
545 \<forall>ia j. tl (Bk\<^bsup>t\<^esup> @ Oc\<^bsup>i\<^esup>) = Bk\<^bsup>j - Suc 0\<^esup> @ Oc\<^bsup>ia\<^esup> \<longrightarrow> |
|
546 ia + j = Suc x \<longrightarrow> ia = 0 \<or> j = 0 \<or> Oc\<^bsup>t\<^esup> \<noteq> Oc\<^bsup>j\<^esup>\<rbrakk> \<Longrightarrow> |
|
547 RR" |
|
548 apply(erule_tac x = i in allE, simp) |
|
549 apply(erule_tac x = t in allE, simp) |
|
550 apply(case_tac t, simp_all add: exp_ind_def exp_zero) |
|
551 done |
|
552 |
|
553 lemma [elim]: "\<lbrakk>tstep (9, b, c) tcopy = (9, ab, ba); |
|
554 tcopy_F9 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F9 x (ab, ba)" |
|
555 apply(auto simp: tcopy_F9.simps tcopy_def |
|
556 tstep.simps fetch.simps new_tape.simps exp_zero_simp exp_zero_simp2 |
|
557 tcopy_F9_exit.simps tcopy_F9_loop.simps |
|
558 split: if_splits list.splits block.splits) |
|
559 apply(case_tac [!] k, simp_all add: exp_ind_def exp_zero) |
|
560 apply(erule_tac [!] x = i in allE, simp) |
|
561 apply(erule_tac false_case7, simp_all)+ |
|
562 apply(case_tac t, simp_all add: exp_zero exp_ind_def) |
|
563 apply(erule_tac false_case7, simp_all)+ |
|
564 apply(erule_tac false_case8, simp_all) |
|
565 apply(erule_tac false_case7, simp_all)+ |
|
566 apply(case_tac t, simp_all add: exp_ind_def exp_zero) |
|
567 apply(erule_tac false_case7, simp_all) |
|
568 apply(erule_tac false_case8, simp_all) |
|
569 apply(erule_tac false_case7, simp_all) |
|
570 done |
|
571 |
|
572 lemma [elim]: "\<lbrakk>tstep (8, b, c) tcopy = (9, ab, ba); |
|
573 tcopy_F8 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F9 x (ab, ba)" |
|
574 apply(auto simp:tcopy_F8.simps tcopy_F9.simps tcopy_def |
|
575 tstep.simps fetch.simps new_tape.simps tcopy_F9_loop.simps |
|
576 tcopy_F9_exit.simps |
|
577 split: if_splits list.splits block.splits) |
|
578 apply(case_tac [!] t, simp_all add: exp_ind_def exp_zero) |
|
579 apply(rule_tac x = i in exI) |
|
580 apply(rule_tac x = "Suc k" in exI, simp) |
|
581 apply(rule_tac x = "k" in exI, simp add: exp_ind_def exp_zero) |
|
582 done |
|
583 |
|
584 |
|
585 lemma [elim]: "\<lbrakk>tstep (8, b, c) tcopy = (8, ab, ba); |
|
586 tcopy_F8 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F8 x (ab, ba)" |
|
587 apply(auto simp:tcopy_F8.simps tcopy_def tstep.simps |
|
588 fetch.simps new_tape.simps exp_zero_simp exp_zero split: if_splits list.splits |
|
589 |
|
590 block.splits) |
|
591 apply(rule_tac x = i in exI, rule_tac x = "k + t" in exI, simp) |
|
592 apply(rule_tac x = "Suc k" in exI, simp) |
|
593 apply(rule_tac x = "t - 1" in exI, simp) |
|
594 apply(case_tac t, simp_all add: exp_zero exp_ind_def) |
|
595 done |
|
596 |
|
597 |
|
598 lemma [elim]: "\<lbrakk>tstep (7, b, c) tcopy = (7, ab, ba); |
|
599 tcopy_F7 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F7 x (ab, ba)" |
|
600 apply(auto simp:tcopy_F7.simps tcopy_def tstep.simps fetch.simps |
|
601 new_tape.simps exp_ind_def exp_zero_simp |
|
602 split: if_splits list.splits block.splits) |
|
603 apply(rule_tac x = i in exI) |
|
604 apply(rule_tac x = j in exI, simp) |
|
605 apply(rule_tac x = "Suc k" in exI, simp) |
|
606 apply(rule_tac x = "t - 1" in exI) |
|
607 apply(case_tac t, simp_all add: exp_zero exp_ind_def) |
|
608 apply(case_tac j, simp_all add: exp_zero exp_ind_def) |
|
609 done |
|
610 |
|
611 lemma [elim]: "\<lbrakk>tstep (7, b, c) tcopy = (8, ab, ba); |
|
612 tcopy_F7 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F8 x (ab, ba)" |
|
613 apply(auto simp:tcopy_F7.simps tcopy_def tstep.simps tcopy_F8.simps |
|
614 fetch.simps new_tape.simps exp_zero_simp |
|
615 split: if_splits list.splits block.splits) |
|
616 apply(rule_tac x = i in exI, simp) |
|
617 apply(rule_tac x = "Suc 0" in exI, simp add: exp_ind_def exp_zero) |
|
618 apply(rule_tac x = "j - 1" in exI, simp) |
|
619 apply(case_tac t, simp_all add: exp_ind_def ) |
|
620 apply(case_tac j, simp_all add: exp_ind_def exp_zero) |
|
621 done |
|
622 |
|
623 lemma [elim]: "\<lbrakk>tstep (6, b, c) tcopy = (7, ab, ba); |
|
624 tcopy_F6 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F7 x (ab, ba)" |
|
625 apply(case_tac x) |
|
626 apply(auto simp:tcopy_F7.simps tcopy_F6.simps |
|
627 tcopy_def tstep.simps fetch.simps new_tape.simps exp_zero_simp |
|
628 split: if_splits list.splits block.splits) |
|
629 apply(case_tac i, simp_all add: exp_ind_def exp_zero) |
|
630 apply(rule_tac x = i in exI, simp) |
|
631 apply(rule_tac x = j in exI, simp) |
|
632 apply(rule_tac x = "Suc 0" in exI, simp add: exp_ind_def exp_zero) |
|
633 done |
|
634 |
|
635 lemma [elim]: "\<lbrakk>tstep (6, b, c) tcopy = (6, ab, ba); |
|
636 tcopy_F6 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F6 x (ab, ba)" |
|
637 apply(auto simp:tcopy_F6.simps tcopy_def tstep.simps |
|
638 new_tape.simps fetch.simps |
|
639 split: if_splits list.splits block.splits) |
|
640 done |
|
641 |
|
642 lemma [elim]: "\<lbrakk>tstep (5, b, c) tcopy = (6, ab, ba); |
|
643 tcopy_F5 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F6 x (ab, ba)" |
|
644 apply(auto simp:tcopy_F5.simps tcopy_F6.simps tcopy_def |
|
645 tstep.simps fetch.simps new_tape.simps exp_zero_simp2 |
|
646 split: if_splits list.splits block.splits) |
|
647 apply(rule_tac x = "Suc 0" in exI, simp add: exp_ind_def exp_zero) |
|
648 apply(rule_tac x = "Suc i" in exI, simp add: exp_ind_def) |
|
649 done |
|
650 |
|
651 lemma [elim]: "\<lbrakk>tstep (10, b, c) tcopy = (5, ab, ba); |
|
652 tcopy_F10 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F5 x (ab, ba)" |
|
653 apply(auto simp:tcopy_F5.simps tcopy_F10.simps tcopy_def |
|
654 tstep.simps fetch.simps new_tape.simps exp_zero_simp exp_zero_simp2 |
|
655 exp_ind_def tcopy_F10.simps tcopy_F10_loop.simps tcopy_F10_exit.simps |
|
656 split: if_splits list.splits block.splits ) |
|
657 apply(erule_tac [!] x = "i - 1" in allE) |
|
658 apply(erule_tac [!] x = j in allE, simp_all) |
|
659 apply(case_tac [!] i, simp_all add: exp_ind_def) |
|
660 done |
|
661 |
|
662 lemma [elim]: "\<lbrakk>tstep (4, b, c) tcopy = (5, ab, ba); |
|
663 tcopy_F4 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F5 x (ab, ba)" |
|
664 apply(auto simp:tcopy_F5.simps tcopy_F4.simps tcopy_def |
|
665 tstep.simps fetch.simps new_tape.simps exp_zero_simp exp_zero_simp2 |
|
666 split: if_splits list.splits block.splits) |
|
667 apply(case_tac x, simp, simp add: exp_ind_def exp_zero) |
|
668 apply(erule_tac [!] x = "x - 2" in allE) |
|
669 apply(erule_tac [!] x = "Suc 0" in allE) |
|
670 apply(case_tac [!] x, simp_all add: exp_ind_def exp_zero) |
|
671 apply(case_tac [!] nat, simp_all add: exp_ind_def exp_zero) |
|
672 done |
|
673 |
|
674 lemma [elim]: "\<lbrakk>tstep (3, b, c) tcopy = (4, ab, ba); |
|
675 tcopy_F3 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F4 x (ab, ba)" |
|
676 apply(auto simp:tcopy_F3.simps tcopy_F4.simps |
|
677 tcopy_def tstep.simps fetch.simps new_tape.simps |
|
678 split: if_splits list.splits block.splits) |
|
679 done |
|
680 |
|
681 lemma [elim]: "\<lbrakk>tstep (4, b, c) tcopy = (4, ab, ba); |
|
682 tcopy_F4 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F4 x (ab, ba)" |
|
683 apply(case_tac x) |
|
684 apply(auto simp:tcopy_F3.simps tcopy_F4.simps |
|
685 tcopy_def tstep.simps fetch.simps new_tape.simps exp_zero_simp exp_zero_simp2 exp_ind_def |
|
686 split: if_splits list.splits block.splits) |
|
687 done |
|
688 |
|
689 lemma [elim]: "\<lbrakk>tstep (3, b, c) tcopy = (3, ab, ba); |
|
690 tcopy_F3 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F3 x (ab, ba)" |
|
691 apply(auto simp:tcopy_F3.simps tcopy_F4.simps |
|
692 tcopy_def tstep.simps fetch.simps new_tape.simps |
|
693 split: if_splits list.splits block.splits) |
|
694 done |
|
695 |
|
696 lemma [elim]: "\<lbrakk>tstep (2, b, c) tcopy = (3, ab, ba); |
|
697 tcopy_F2 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F3 x (ab, ba)" |
|
698 apply(case_tac x) |
|
699 apply(auto simp:tcopy_F3.simps tcopy_F2.simps |
|
700 tcopy_def tstep.simps fetch.simps new_tape.simps |
|
701 exp_zero_simp exp_zero_simp2 exp_zero |
|
702 split: if_splits list.splits block.splits) |
|
703 apply(case_tac [!] j, simp_all add: exp_zero exp_ind_def) |
|
704 done |
|
705 |
|
706 lemma [elim]: "\<lbrakk>tstep (2, b, c) tcopy = (2, ab, ba); |
|
707 tcopy_F2 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F2 x (ab, ba)" |
|
708 apply(auto simp:tcopy_F3.simps tcopy_F2.simps |
|
709 tcopy_def tstep.simps fetch.simps new_tape.simps |
|
710 exp_zero_simp exp_zero_simp2 exp_zero |
|
711 split: if_splits list.splits block.splits) |
|
712 apply(rule_tac x = "Suc i" in exI, simp add: exp_ind_def exp_zero) |
|
713 apply(rule_tac x = "j - 1" in exI, simp) |
|
714 apply(case_tac j, simp_all add: exp_ind_def exp_zero) |
|
715 done |
|
716 |
|
717 lemma [elim]: "\<lbrakk>tstep (Suc 0, b, c) tcopy = (2, ab, ba); |
|
718 tcopy_F1 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F2 x (ab, ba)" |
|
719 apply(auto simp:tcopy_F1.simps tcopy_F2.simps |
|
720 tcopy_def tstep.simps fetch.simps new_tape.simps |
|
721 exp_zero_simp exp_zero_simp2 exp_zero |
|
722 split: if_splits list.splits block.splits) |
|
723 apply(rule_tac x = "Suc 0" in exI, simp) |
|
724 apply(rule_tac x = "x - 1" in exI, simp) |
|
725 apply(case_tac x, simp_all add: exp_ind_def exp_zero) |
|
726 done |
|
727 |
|
728 lemma [elim]: "\<lbrakk>tstep (Suc 0, b, c) tcopy = (0, ab, ba); |
|
729 tcopy_F1 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F0 x (ab, ba)" |
|
730 apply(simp_all add:tcopy_F0.simps tcopy_F1.simps |
|
731 tcopy_def tstep.simps fetch.simps new_tape.simps |
|
732 exp_zero_simp exp_zero_simp2 exp_zero |
|
733 split: if_splits list.splits block.splits ) |
|
734 apply(case_tac x, simp_all add: exp_ind_def exp_zero, auto) |
|
735 done |
|
736 |
|
737 lemma [elim]: "\<lbrakk>tstep (15, b, c) tcopy = (0, ab, ba); |
|
738 tcopy_F15 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F0 x (ab, ba)" |
|
739 apply(auto simp: tcopy_F15.simps tcopy_F0.simps |
|
740 tcopy_def tstep.simps new_tape.simps fetch.simps |
|
741 split: if_splits list.splits block.splits) |
|
742 apply(rule_tac x = "Suc 0" in exI, simp add: exp_ind_def exp_zero) |
|
743 apply(case_tac [!] j, simp_all add: exp_ind_def exp_zero) |
|
744 done |
|
745 |
|
746 |
|
747 lemma [elim]: "\<lbrakk>tstep (0, b, c) tcopy = (0, ab, ba); |
|
748 tcopy_F0 x (b, c)\<rbrakk> \<Longrightarrow> tcopy_F0 x (ab, ba)" |
|
749 apply(case_tac x) |
|
750 apply(simp_all add: tcopy_F0.simps tcopy_def |
|
751 tstep.simps new_tape.simps fetch.simps) |
|
752 done |
|
753 |
|
754 declare tstep.simps[simp del] |
|
755 |
|
756 text {* |
|
757 Finally establishes the invariant of Copying TM, which is used to dervie |
|
758 the parital correctness of Copying TM. |
|
759 *} |
|
760 lemma inv_tcopy_step:"inv_tcopy x c \<Longrightarrow> inv_tcopy x (tstep c tcopy)" |
|
761 apply(induct c) |
|
762 apply(auto split: if_splits block.splits list.splits taction.splits) |
|
763 apply(auto simp: tstep.simps tcopy_def fetch.simps new_tape.simps |
|
764 split: if_splits list.splits block.splits taction.splits) |
|
765 done |
|
766 |
|
767 declare inv_tcopy.simps[simp del] |
|
768 |
|
769 text {* |
|
770 Invariant under mult-step execution. |
|
771 *} |
|
772 lemma inv_tcopy_steps: |
|
773 "inv_tcopy x (steps (Suc 0, [], Oc\<^bsup>x\<^esup>) tcopy stp) " |
|
774 apply(induct stp) |
|
775 apply(simp add: tstep.simps tcopy_def steps.simps |
|
776 tcopy_F1.simps inv_tcopy.simps) |
|
777 apply(drule_tac inv_tcopy_step, simp add: tstep_red) |
|
778 done |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 (*----------halt problem of tcopy----------------------------------------*) |
|
784 |
|
785 section {* |
|
786 The following definitions are used to construct the measure function used to show |
|
787 the termnation of Copying TM. |
|
788 *} |
|
789 |
|
790 definition lex_pair :: "((nat \<times> nat) \<times> nat \<times> nat) set" |
|
791 where |
|
792 "lex_pair \<equiv> less_than <*lex*> less_than" |
|
793 |
|
794 definition lex_triple :: |
|
795 "((nat \<times> (nat \<times> nat)) \<times> (nat \<times> (nat \<times> nat))) set" |
|
796 where |
|
797 "lex_triple \<equiv> less_than <*lex*> lex_pair" |
|
798 |
|
799 definition lex_square :: |
|
800 "((nat \<times> nat \<times> nat \<times> nat) \<times> (nat \<times> nat \<times> nat \<times> nat)) set" |
|
801 where |
|
802 "lex_square \<equiv> less_than <*lex*> lex_triple" |
|
803 |
|
804 lemma wf_lex_triple: "wf lex_triple" |
|
805 by (auto intro:wf_lex_prod simp:lex_triple_def lex_pair_def) |
|
806 |
|
807 lemma wf_lex_square: "wf lex_square" |
|
808 by (auto intro:wf_lex_prod |
|
809 simp:lex_triple_def lex_square_def lex_pair_def) |
|
810 |
|
811 text {* |
|
812 A measurement functions used to show the termination of copying machine: |
|
813 *} |
|
814 fun tcopy_phase :: "t_conf \<Rightarrow> nat" |
|
815 where |
|
816 "tcopy_phase c = (let (state, tp) = c in |
|
817 if state > 0 & state <= 4 then 5 |
|
818 else if state >=5 & state <= 10 then 4 |
|
819 else if state = 11 then 3 |
|
820 else if state = 12 | state = 13 then 2 |
|
821 else if state = 14 | state = 15 then 1 |
|
822 else 0)" |
|
823 |
|
824 fun tcopy_phase4_stage :: "tape \<Rightarrow> nat" |
|
825 where |
|
826 "tcopy_phase4_stage (ln, rn) = |
|
827 (let lrn = (rev ln) @ rn |
|
828 in length (takeWhile (\<lambda>a. a = Oc) lrn))" |
|
829 |
|
830 fun tcopy_stage :: "t_conf \<Rightarrow> nat" |
|
831 where |
|
832 "tcopy_stage c = (let (state, ln, rn) = c in |
|
833 if tcopy_phase c = 5 then 0 |
|
834 else if tcopy_phase c = 4 then |
|
835 tcopy_phase4_stage (ln, rn) |
|
836 else if tcopy_phase c = 3 then 0 |
|
837 else if tcopy_phase c = 2 then length rn |
|
838 else if tcopy_phase c = 1 then 0 |
|
839 else 0)" |
|
840 |
|
841 fun tcopy_phase4_state :: "t_conf \<Rightarrow> nat" |
|
842 where |
|
843 "tcopy_phase4_state c = (let (state, ln, rn) = c in |
|
844 if state = 6 & hd rn = Oc then 0 |
|
845 else if state = 5 then 1 |
|
846 else 12 - state)" |
|
847 |
|
848 fun tcopy_state :: "t_conf \<Rightarrow> nat" |
|
849 where |
|
850 "tcopy_state c = (let (state, ln, rn) = c in |
|
851 if tcopy_phase c = 5 then 4 - state |
|
852 else if tcopy_phase c = 4 then |
|
853 tcopy_phase4_state c |
|
854 else if tcopy_phase c = 3 then 0 |
|
855 else if tcopy_phase c = 2 then 13 - state |
|
856 else if tcopy_phase c = 1 then 15 - state |
|
857 else 0)" |
|
858 |
|
859 fun tcopy_step2 :: "t_conf \<Rightarrow> nat" |
|
860 where |
|
861 "tcopy_step2 (s, l, r) = length r" |
|
862 |
|
863 fun tcopy_step3 :: "t_conf \<Rightarrow> nat" |
|
864 where |
|
865 "tcopy_step3 (s, l, r) = (if r = [] | r = [Bk] then Suc 0 else 0)" |
|
866 |
|
867 fun tcopy_step4 :: "t_conf \<Rightarrow> nat" |
|
868 where |
|
869 "tcopy_step4 (s, l, r) = length l" |
|
870 |
|
871 fun tcopy_step7 :: "t_conf \<Rightarrow> nat" |
|
872 where |
|
873 "tcopy_step7 (s, l, r) = length r" |
|
874 |
|
875 fun tcopy_step8 :: "t_conf \<Rightarrow> nat" |
|
876 where |
|
877 "tcopy_step8 (s, l, r) = length r" |
|
878 |
|
879 fun tcopy_step9 :: "t_conf \<Rightarrow> nat" |
|
880 where |
|
881 "tcopy_step9 (s, l, r) = length l" |
|
882 |
|
883 fun tcopy_step10 :: "t_conf \<Rightarrow> nat" |
|
884 where |
|
885 "tcopy_step10 (s, l, r) = length l" |
|
886 |
|
887 fun tcopy_step14 :: "t_conf \<Rightarrow> nat" |
|
888 where |
|
889 "tcopy_step14 (s, l, r) = (case hd r of |
|
890 Oc \<Rightarrow> 1 | |
|
891 Bk \<Rightarrow> 0)" |
|
892 |
|
893 fun tcopy_step15 :: "t_conf \<Rightarrow> nat" |
|
894 where |
|
895 "tcopy_step15 (s, l, r) = length l" |
|
896 |
|
897 fun tcopy_step :: "t_conf \<Rightarrow> nat" |
|
898 where |
|
899 "tcopy_step c = (let (state, ln, rn) = c in |
|
900 if state = 0 | state = 1 | state = 11 | |
|
901 state = 5 | state = 6 | state = 12 | state = 13 then 0 |
|
902 else if state = 2 then tcopy_step2 c |
|
903 else if state = 3 then tcopy_step3 c |
|
904 else if state = 4 then tcopy_step4 c |
|
905 else if state = 7 then tcopy_step7 c |
|
906 else if state = 8 then tcopy_step8 c |
|
907 else if state = 9 then tcopy_step9 c |
|
908 else if state = 10 then tcopy_step10 c |
|
909 else if state = 14 then tcopy_step14 c |
|
910 else if state = 15 then tcopy_step15 c |
|
911 else 0)" |
|
912 |
|
913 text {* |
|
914 The measure function used to show the termination of Copying TM. |
|
915 *} |
|
916 fun tcopy_measure :: "t_conf \<Rightarrow> (nat * nat * nat * nat)" |
|
917 where |
|
918 "tcopy_measure c = |
|
919 (tcopy_phase c, tcopy_stage c, tcopy_state c, tcopy_step c)" |
|
920 |
|
921 definition tcopy_LE :: "((nat \<times> block list \<times> block list) \<times> |
|
922 (nat \<times> block list \<times> block list)) set" |
|
923 where |
|
924 "tcopy_LE \<equiv> (inv_image lex_square tcopy_measure)" |
|
925 |
|
926 lemma wf_tcopy_le: "wf tcopy_LE" |
|
927 by(auto intro:wf_inv_image wf_lex_square simp:tcopy_LE_def) |
|
928 |
|
929 |
|
930 declare steps.simps[simp del] |
|
931 |
|
932 declare tcopy_phase.simps[simp del] tcopy_stage.simps[simp del] |
|
933 tcopy_state.simps[simp del] tcopy_step.simps[simp del] |
|
934 inv_tcopy.simps[simp del] |
|
935 declare tcopy_F0.simps [simp] |
|
936 tcopy_F1.simps [simp] |
|
937 tcopy_F2.simps [simp] |
|
938 tcopy_F3.simps [simp] |
|
939 tcopy_F4.simps [simp] |
|
940 tcopy_F5.simps [simp] |
|
941 tcopy_F6.simps [simp] |
|
942 tcopy_F7.simps [simp] |
|
943 tcopy_F8.simps [simp] |
|
944 tcopy_F9.simps [simp] |
|
945 tcopy_F10.simps [simp] |
|
946 tcopy_F11.simps [simp] |
|
947 tcopy_F12.simps [simp] |
|
948 tcopy_F13.simps [simp] |
|
949 tcopy_F14.simps [simp] |
|
950 tcopy_F15.simps [simp] |
|
951 fetch.simps[simp] |
|
952 new_tape.simps[simp] |
|
953 lemma [elim]: "tcopy_F1 x (b, c) \<Longrightarrow> |
|
954 (tstep (Suc 0, b, c) tcopy, Suc 0, b, c) \<in> tcopy_LE" |
|
955 apply(simp add: tcopy_F1.simps tstep.simps tcopy_def tcopy_LE_def |
|
956 lex_square_def lex_triple_def lex_pair_def tcopy_phase.simps |
|
957 tcopy_stage.simps tcopy_state.simps tcopy_step.simps) |
|
958 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
959 done |
|
960 |
|
961 lemma [elim]: "tcopy_F2 x (b, c) \<Longrightarrow> |
|
962 (tstep (2, b, c) tcopy, 2, b, c) \<in> tcopy_LE" |
|
963 apply(simp add:tstep.simps tcopy_def tcopy_LE_def lex_square_def |
|
964 lex_triple_def lex_pair_def tcopy_phase.simps tcopy_stage.simps |
|
965 tcopy_state.simps tcopy_step.simps) |
|
966 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
967 done |
|
968 |
|
969 lemma [elim]: "tcopy_F3 x (b, c) \<Longrightarrow> |
|
970 (tstep (3, b, c) tcopy, 3, b, c) \<in> tcopy_LE" |
|
971 apply(simp add: tstep.simps tcopy_def tcopy_LE_def lex_square_def |
|
972 lex_triple_def lex_pair_def tcopy_phase.simps tcopy_stage.simps |
|
973 tcopy_state.simps tcopy_step.simps) |
|
974 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
975 apply(auto) |
|
976 done |
|
977 |
|
978 lemma [elim]: "tcopy_F4 x (b, c) \<Longrightarrow> |
|
979 (tstep (4, b, c) tcopy, 4, b, c) \<in> tcopy_LE" |
|
980 apply(case_tac x, simp) |
|
981 apply(simp add: tcopy_F4.simps tstep.simps tcopy_def tcopy_LE_def |
|
982 lex_square_def lex_triple_def lex_pair_def tcopy_phase.simps |
|
983 tcopy_stage.simps tcopy_state.simps tcopy_step.simps) |
|
984 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
985 apply(auto simp: exp_ind_def) |
|
986 done |
|
987 |
|
988 lemma[simp]: "takeWhile (\<lambda>a. a = b) (replicate x b @ ys) = |
|
989 replicate x b @ (takeWhile (\<lambda>a. a = b) ys)" |
|
990 apply(induct x) |
|
991 apply(simp+) |
|
992 done |
|
993 |
|
994 lemma [elim]: "tcopy_F5 x (b, c) \<Longrightarrow> |
|
995 (tstep (5, b, c) tcopy, 5, b, c) \<in> tcopy_LE" |
|
996 apply(case_tac x, simp) |
|
997 apply(simp add: tstep.simps tcopy_def tcopy_LE_def |
|
998 lex_square_def lex_triple_def lex_pair_def tcopy_phase.simps) |
|
999 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
1000 apply(auto) |
|
1001 apply(simp_all add: tcopy_phase.simps |
|
1002 tcopy_stage.simps tcopy_state.simps) |
|
1003 done |
|
1004 |
|
1005 lemma [elim]: "\<lbrakk>replicate n x = []; n > 0\<rbrakk> \<Longrightarrow> RR" |
|
1006 apply(case_tac n, simp+) |
|
1007 done |
|
1008 |
|
1009 lemma [elim]: "tcopy_F6 x (b, c) \<Longrightarrow> |
|
1010 (tstep (6, b, c) tcopy, 6, b, c) \<in> tcopy_LE" |
|
1011 apply(case_tac x, simp) |
|
1012 apply(simp add: tstep.simps tcopy_def tcopy_LE_def |
|
1013 lex_square_def lex_triple_def lex_pair_def |
|
1014 tcopy_phase.simps) |
|
1015 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
1016 apply(auto) |
|
1017 apply(simp_all add: tcopy_phase.simps tcopy_stage.simps |
|
1018 tcopy_state.simps tcopy_step.simps exponent_def) |
|
1019 done |
|
1020 |
|
1021 lemma [elim]: "tcopy_F7 x (b, c) \<Longrightarrow> |
|
1022 (tstep (7, b, c) tcopy, 7, b, c) \<in> tcopy_LE" |
|
1023 apply(case_tac x, simp) |
|
1024 apply(simp add: tstep.simps tcopy_def tcopy_LE_def lex_square_def |
|
1025 lex_triple_def lex_pair_def tcopy_phase.simps) |
|
1026 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
1027 apply(auto simp: exp_zero_simp) |
|
1028 apply(simp_all add: tcopy_phase.simps tcopy_stage.simps |
|
1029 tcopy_state.simps tcopy_step.simps) |
|
1030 done |
|
1031 |
|
1032 lemma [elim]: "tcopy_F8 x (b, c) \<Longrightarrow> |
|
1033 (tstep (8, b, c) tcopy, 8, b, c) \<in> tcopy_LE" |
|
1034 apply(case_tac x, simp) |
|
1035 apply(simp add: tstep.simps tcopy_def tcopy_LE_def lex_square_def |
|
1036 lex_triple_def lex_pair_def tcopy_phase.simps) |
|
1037 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
1038 apply(auto simp: exp_zero_simp) |
|
1039 apply(simp_all add: tcopy_phase.simps tcopy_stage.simps |
|
1040 tcopy_state.simps tcopy_step.simps exponent_def) |
|
1041 done |
|
1042 |
|
1043 lemma rev_equal_rev: "rev a = rev b \<Longrightarrow> a = b" |
|
1044 by simp |
|
1045 |
|
1046 lemma app_app_app_equal: "xs @ ys @ zs = (xs @ ys) @ zs" |
|
1047 by simp |
|
1048 |
|
1049 lemma append_cons_assoc: "as @ b # bs = (as @ [b]) @ bs" |
|
1050 apply(rule rev_equal_rev) |
|
1051 apply(simp) |
|
1052 done |
|
1053 |
|
1054 lemma rev_tl_hd_merge: "bs \<noteq> [] \<Longrightarrow> |
|
1055 rev (tl bs) @ hd bs # as = rev bs @ as" |
|
1056 apply(rule rev_equal_rev) |
|
1057 apply(simp) |
|
1058 done |
|
1059 |
|
1060 lemma[simp]: "takeWhile (\<lambda>a. a = b) (replicate x b @ ys) = |
|
1061 replicate x b @ (takeWhile (\<lambda>a. a = b) ys)" |
|
1062 apply(induct x) |
|
1063 apply(simp+) |
|
1064 done |
|
1065 |
|
1066 lemma [elim]: "tcopy_F9 x (b, c) \<Longrightarrow> |
|
1067 (tstep (9, b, c) tcopy, 9, b, c) \<in> tcopy_LE" |
|
1068 apply(simp add: tstep.simps tcopy_def tcopy_LE_def lex_square_def |
|
1069 lex_triple_def lex_pair_def tcopy_phase.simps tcopy_F9.simps |
|
1070 tcopy_F9_loop.simps tcopy_F9_exit.simps) |
|
1071 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
1072 apply(auto) |
|
1073 apply(simp_all add: tcopy_phase.simps tcopy_stage.simps tcopy_F9_loop.simps |
|
1074 tcopy_state.simps tcopy_step.simps tstep.simps exp_zero_simp |
|
1075 exponent_def) |
|
1076 apply(case_tac [1-2] t, simp_all add: rev_tl_hd_merge) |
|
1077 apply(case_tac j, simp, simp) |
|
1078 apply(case_tac nat, simp_all) |
|
1079 apply(case_tac nata, simp_all) |
|
1080 done |
|
1081 |
|
1082 lemma [elim]: "tcopy_F10 x (b, c) \<Longrightarrow> |
|
1083 (tstep (10, b, c) tcopy, 10, b, c) \<in> tcopy_LE" |
|
1084 apply(simp add: tstep.simps tcopy_def tcopy_LE_def lex_square_def |
|
1085 lex_triple_def lex_pair_def tcopy_phase.simps tcopy_F10_loop.simps |
|
1086 tcopy_F10_exit.simps exp_zero_simp) |
|
1087 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
1088 apply(auto simp: exp_zero_simp) |
|
1089 apply(simp_all add: tcopy_phase.simps tcopy_stage.simps |
|
1090 tcopy_state.simps tcopy_step.simps exponent_def |
|
1091 rev_tl_hd_merge) |
|
1092 apply(case_tac k, simp_all) |
|
1093 apply(case_tac nat, simp_all) |
|
1094 done |
|
1095 |
|
1096 lemma [elim]: "tcopy_F11 x (b, c) \<Longrightarrow> |
|
1097 (tstep (11, b, c) tcopy, 11, b, c) \<in> tcopy_LE" |
|
1098 apply(case_tac x, simp) |
|
1099 apply(simp add: tstep.simps tcopy_def tcopy_LE_def |
|
1100 lex_square_def lex_triple_def lex_pair_def |
|
1101 tcopy_phase.simps) |
|
1102 done |
|
1103 |
|
1104 lemma [elim]: "tcopy_F12 x (b, c) \<Longrightarrow> |
|
1105 (tstep (12, b, c) tcopy, 12, b, c) \<in> tcopy_LE" |
|
1106 apply(case_tac x, simp) |
|
1107 apply(simp add: tstep.simps tcopy_def tcopy_LE_def lex_square_def |
|
1108 lex_triple_def lex_pair_def tcopy_phase.simps) |
|
1109 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
1110 apply(auto) |
|
1111 apply(simp_all add: tcopy_phase.simps tcopy_stage.simps |
|
1112 tcopy_state.simps tcopy_step.simps) |
|
1113 apply(simp_all add: exp_ind_def) |
|
1114 done |
|
1115 |
|
1116 lemma [elim]: "tcopy_F13 x (b, c) \<Longrightarrow> |
|
1117 (tstep (13, b, c) tcopy, 13, b, c) \<in> tcopy_LE" |
|
1118 apply(case_tac x, simp) |
|
1119 apply(simp add: tstep.simps tcopy_def tcopy_LE_def lex_square_def |
|
1120 lex_triple_def lex_pair_def tcopy_phase.simps) |
|
1121 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
1122 apply(auto) |
|
1123 apply(simp_all add: tcopy_phase.simps tcopy_stage.simps |
|
1124 tcopy_state.simps tcopy_step.simps) |
|
1125 done |
|
1126 |
|
1127 lemma [elim]: "tcopy_F14 x (b, c) \<Longrightarrow> |
|
1128 (tstep (14, b, c) tcopy, 14, b, c) \<in> tcopy_LE" |
|
1129 apply(case_tac x, simp) |
|
1130 apply(simp add: tstep.simps tcopy_def tcopy_LE_def lex_square_def |
|
1131 lex_triple_def lex_pair_def tcopy_phase.simps) |
|
1132 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
1133 apply(auto) |
|
1134 apply(simp_all add: tcopy_phase.simps tcopy_stage.simps |
|
1135 tcopy_state.simps tcopy_step.simps) |
|
1136 done |
|
1137 |
|
1138 lemma [elim]: "tcopy_F15 x (b, c) \<Longrightarrow> |
|
1139 (tstep (15, b, c) tcopy, 15, b, c) \<in> tcopy_LE" |
|
1140 apply(case_tac x, simp) |
|
1141 apply(simp add: tstep.simps tcopy_def tcopy_LE_def lex_square_def |
|
1142 lex_triple_def lex_pair_def tcopy_phase.simps ) |
|
1143 apply(simp split: if_splits list.splits block.splits taction.splits) |
|
1144 apply(auto) |
|
1145 apply(simp_all add: tcopy_phase.simps tcopy_stage.simps |
|
1146 tcopy_state.simps tcopy_step.simps) |
|
1147 done |
|
1148 |
|
1149 lemma exp_length: "length (a\<^bsup>b\<^esup>) = b" |
|
1150 apply(induct b, simp_all add: exp_zero exp_ind_def) |
|
1151 done |
|
1152 |
|
1153 declare tcopy_F9.simps[simp del] tcopy_F10.simps[simp del] |
|
1154 |
|
1155 lemma length_eq: "xs = ys \<Longrightarrow> length xs = length ys" |
|
1156 by simp |
|
1157 |
|
1158 lemma tcopy_wf_step:"\<lbrakk>a > 0; inv_tcopy x (a, b, c)\<rbrakk> \<Longrightarrow> |
|
1159 (tstep (a, b, c) tcopy, (a, b, c)) \<in> tcopy_LE" |
|
1160 apply(simp add:inv_tcopy.simps split: if_splits, auto) |
|
1161 apply(auto simp: tstep.simps tcopy_def tcopy_LE_def lex_square_def |
|
1162 lex_triple_def lex_pair_def tcopy_phase.simps |
|
1163 tcopy_stage.simps tcopy_state.simps tcopy_step.simps |
|
1164 exp_length exp_zero_simp exponent_def |
|
1165 split: if_splits list.splits block.splits taction.splits) |
|
1166 apply(case_tac [!] t, simp_all) |
|
1167 apply(case_tac j, simp_all) |
|
1168 apply(drule_tac length_eq, simp) |
|
1169 done |
|
1170 |
|
1171 lemma tcopy_wf: |
|
1172 "\<forall>n. let nc = steps (Suc 0, [], Oc\<^bsup>x\<^esup>) tcopy n in |
|
1173 let Sucnc = steps (Suc 0, [], Oc\<^bsup>x\<^esup>) tcopy (Suc n) in |
|
1174 \<not> isS0 nc \<longrightarrow> ((Sucnc, nc) \<in> tcopy_LE)" |
|
1175 proof(rule allI, case_tac |
|
1176 "steps (Suc 0, [], Oc\<^bsup>x\<^esup>) tcopy n", auto simp: tstep_red) |
|
1177 fix n a b c |
|
1178 assume h: "\<not> isS0 (a, b, c)" |
|
1179 "steps (Suc 0, [], Oc\<^bsup>x\<^esup>) tcopy n = (a, b, c)" |
|
1180 hence "inv_tcopy x (a, b, c)" |
|
1181 using inv_tcopy_steps[of x n] by(simp) |
|
1182 thus "(tstep (a, b, c) tcopy, a, b, c) \<in> tcopy_LE" |
|
1183 using h |
|
1184 by(rule_tac tcopy_wf_step, auto simp: isS0_def) |
|
1185 qed |
|
1186 |
|
1187 text {* |
|
1188 The termination of Copying TM: |
|
1189 *} |
|
1190 lemma tcopy_halt: |
|
1191 "\<exists>n. isS0 (steps (Suc 0, [], Oc\<^bsup>x\<^esup>) tcopy n)" |
|
1192 apply(insert halt_lemma |
|
1193 [of tcopy_LE isS0 "steps (Suc 0, [], Oc\<^bsup>x\<^esup>) tcopy"]) |
|
1194 apply(insert tcopy_wf [of x]) |
|
1195 apply(simp only: Let_def) |
|
1196 apply(insert wf_tcopy_le) |
|
1197 apply(simp) |
|
1198 done |
|
1199 |
|
1200 text {* |
|
1201 The total correntess of Copying TM: |
|
1202 *} |
|
1203 theorem tcopy_halt_rs: |
|
1204 "\<exists>stp m. |
|
1205 steps (Suc 0, [], Oc\<^bsup>x\<^esup>) tcopy stp = |
|
1206 (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>x\<^esup> @ Bk # Oc\<^bsup>x\<^esup>)" |
|
1207 using tcopy_halt[of x] |
|
1208 proof(erule_tac exE) |
|
1209 fix n |
|
1210 assume h: "isS0 (steps (Suc 0, [], Oc\<^bsup>x\<^esup>) tcopy n)" |
|
1211 have "inv_tcopy x (steps (Suc 0, [], Oc\<^bsup>x\<^esup>) tcopy n)" |
|
1212 using inv_tcopy_steps[of x n] by simp |
|
1213 thus "?thesis" |
|
1214 using h |
|
1215 apply(cases "(steps (Suc 0, [], Oc\<^bsup>x\<^esup>) tcopy n)", |
|
1216 auto simp: isS0_def inv_tcopy.simps) |
|
1217 done |
|
1218 qed |
|
1219 |
|
1220 section {* |
|
1221 The {\em Dithering} Turing Machine |
|
1222 *} |
|
1223 |
|
1224 text {* |
|
1225 The {\em Dithering} TM, when the input is @{text "1"}, it will loop forever, otherwise, it will |
|
1226 terminate. |
|
1227 *} |
|
1228 definition dither :: "tprog" |
|
1229 where |
|
1230 "dither \<equiv> [(W0, 1), (R, 2), (L, 1), (L, 0)] " |
|
1231 |
|
1232 lemma dither_halt_rs: |
|
1233 "\<exists> stp. steps (Suc 0, Bk\<^bsup>m\<^esup>, [Oc, Oc]) dither stp = |
|
1234 (0, Bk\<^bsup>m\<^esup>, [Oc, Oc])" |
|
1235 apply(rule_tac x = "Suc (Suc (Suc 0))" in exI) |
|
1236 apply(simp add: dither_def steps.simps |
|
1237 tstep.simps fetch.simps new_tape.simps) |
|
1238 done |
|
1239 |
|
1240 lemma dither_unhalt_state: |
|
1241 "(steps (Suc 0, Bk\<^bsup>m\<^esup>, [Oc]) dither stp = |
|
1242 (Suc 0, Bk\<^bsup>m\<^esup>, [Oc])) \<or> |
|
1243 (steps (Suc 0, Bk\<^bsup>m\<^esup>, [Oc]) dither stp = (2, Oc # Bk\<^bsup>m\<^esup>, []))" |
|
1244 apply(induct stp, simp add: steps.simps) |
|
1245 apply(simp add: tstep_red, auto) |
|
1246 apply(auto simp: tstep.simps fetch.simps dither_def new_tape.simps) |
|
1247 done |
|
1248 |
|
1249 lemma dither_unhalt_rs: |
|
1250 "\<not> (\<exists> stp. isS0 (steps (Suc 0, Bk\<^bsup>m\<^esup>, [Oc]) dither stp))" |
|
1251 proof(auto) |
|
1252 fix stp |
|
1253 assume h1: "isS0 (steps (Suc 0, Bk\<^bsup>m\<^esup>, [Oc]) dither stp)" |
|
1254 have "\<not> isS0 ((steps (Suc 0, Bk\<^bsup>m\<^esup>, [Oc]) dither stp))" |
|
1255 using dither_unhalt_state[of m stp] |
|
1256 by(auto simp: isS0_def) |
|
1257 from h1 and this show False by (auto) |
|
1258 qed |
|
1259 |
|
1260 section {* |
|
1261 The final diagnal arguments to show the undecidability of Halting problem. |
|
1262 *} |
|
1263 |
|
1264 text {* |
|
1265 @{text "haltP tp x"} means TM @{text "tp"} terminates on input @{text "x"} |
|
1266 and the final configuration is standard. |
|
1267 *} |
|
1268 definition haltP :: "tprog \<Rightarrow> nat \<Rightarrow> bool" |
|
1269 where |
|
1270 "haltP t x = (\<exists>n a b c. steps (Suc 0, [], Oc\<^bsup>x\<^esup>) t n = (0, Bk\<^bsup>a\<^esup>, Oc\<^bsup>b\<^esup> @ Bk\<^bsup>c\<^esup>))" |
|
1271 |
|
1272 lemma [simp]: "length (A |+| B) = length A + length B" |
|
1273 by(auto simp: t_add.simps tshift.simps) |
|
1274 |
|
1275 lemma [intro]: "\<lbrakk>iseven (x::nat); iseven y\<rbrakk> \<Longrightarrow> iseven (x + y)" |
|
1276 apply(auto simp: iseven_def) |
|
1277 apply(rule_tac x = "x + xa" in exI, simp) |
|
1278 done |
|
1279 |
|
1280 lemma t_correct_add[intro]: |
|
1281 "\<lbrakk>t_correct A; t_correct B\<rbrakk> \<Longrightarrow> t_correct (A |+| B)" |
|
1282 apply(auto simp: t_correct.simps tshift.simps t_add.simps |
|
1283 change_termi_state.simps list_all_iff) |
|
1284 apply(erule_tac x = "(a, b)" in ballE, auto) |
|
1285 apply(case_tac "ba = 0", auto) |
|
1286 done |
|
1287 |
|
1288 lemma [intro]: "t_correct tcopy" |
|
1289 apply(simp add: t_correct.simps tcopy_def iseven_def) |
|
1290 apply(rule_tac x = 15 in exI, simp) |
|
1291 done |
|
1292 |
|
1293 lemma [intro]: "t_correct dither" |
|
1294 apply(simp add: t_correct.simps dither_def iseven_def) |
|
1295 apply(rule_tac x = 2 in exI, simp) |
|
1296 done |
|
1297 |
|
1298 text {* |
|
1299 The following locale specifies that TM @{text "H"} can be used to solve |
|
1300 the {\em Halting Problem} and @{text "False"} is going to be derived |
|
1301 under this locale. Therefore, the undecidability of {\em Halting Problem} |
|
1302 is established. |
|
1303 *} |
|
1304 locale uncomputable = |
|
1305 -- {* The coding function of TM, interestingly, the detailed definition of this |
|
1306 funciton @{text "code"} does not affect the final result. *} |
|
1307 fixes code :: "tprog \<Rightarrow> nat" |
|
1308 -- {* |
|
1309 The TM @{text "H"} is the one which is assummed being able to solve the Halting problem. |
|
1310 *} |
|
1311 and H :: "tprog" |
|
1312 assumes h_wf[intro]: "t_correct H" |
|
1313 -- {* |
|
1314 The following two assumptions specifies that @{text "H"} does solve the Halting problem. |
|
1315 *} |
|
1316 and h_case: |
|
1317 "\<And> M n. \<lbrakk>(haltP M n)\<rbrakk> \<Longrightarrow> |
|
1318 \<exists> na nb. (steps (Suc 0, [], Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na = (0, Bk\<^bsup>nb\<^esup>, [Oc]))" |
|
1319 and nh_case: |
|
1320 "\<And> M n. \<lbrakk>(\<not> haltP M n)\<rbrakk> \<Longrightarrow> |
|
1321 \<exists> na nb. (steps (Suc 0, [], Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na = (0, Bk\<^bsup>nb\<^esup>, [Oc, Oc]))" |
|
1322 begin |
|
1323 |
|
1324 term t_correct |
|
1325 declare haltP_def[simp del] |
|
1326 definition tcontra :: "tprog \<Rightarrow> tprog" |
|
1327 where |
|
1328 "tcontra h \<equiv> ((tcopy |+| h) |+| dither)" |
|
1329 |
|
1330 lemma [simp]: "a\<^bsup>0\<^esup> = []" |
|
1331 by(simp add: exponent_def) |
|
1332 |
|
1333 lemma tinres_ex1: |
|
1334 "tinres (Bk\<^bsup>nb\<^esup>) b \<Longrightarrow> \<exists>nb. b = Bk\<^bsup>nb\<^esup>" |
|
1335 apply(auto simp: tinres_def) |
|
1336 proof - |
|
1337 fix n |
|
1338 assume "Bk\<^bsup>nb\<^esup> = b @ Bk\<^bsup>n\<^esup>" |
|
1339 thus "\<exists>nb. b = Bk\<^bsup>nb\<^esup>" |
|
1340 proof(induct b arbitrary: nb) |
|
1341 show "\<exists>nb. [] = Bk\<^bsup>nb\<^esup>" |
|
1342 by(rule_tac x = 0 in exI, simp add: exp_zero) |
|
1343 next |
|
1344 fix a b nb |
|
1345 assume ind: "\<And>nb. Bk\<^bsup>nb\<^esup> = b @ Bk\<^bsup>n\<^esup> \<Longrightarrow> \<exists>nb. b = Bk\<^bsup>nb\<^esup>" |
|
1346 and h: "Bk\<^bsup>nb\<^esup> = (a # b) @ Bk\<^bsup>n\<^esup>" |
|
1347 from h show "\<exists>nb. a # b = Bk\<^bsup>nb\<^esup>" |
|
1348 proof(case_tac a, case_tac nb, simp_all add: exp_ind_def) |
|
1349 fix nat |
|
1350 assume "Bk\<^bsup>nat\<^esup> = b @ Bk\<^bsup>n\<^esup>" |
|
1351 thus "\<exists>nb. Bk # b = Bk\<^bsup>nb\<^esup>" |
|
1352 using ind[of nat] |
|
1353 apply(auto) |
|
1354 apply(rule_tac x = "Suc nb" in exI, simp add: exp_ind_def) |
|
1355 done |
|
1356 next |
|
1357 assume "Bk\<^bsup>nb\<^esup> = Oc # b @ Bk\<^bsup>n\<^esup>" |
|
1358 thus "\<exists>nb. Oc # b = Bk\<^bsup>nb\<^esup>" |
|
1359 apply(case_tac nb, simp_all add: exp_ind_def) |
|
1360 done |
|
1361 qed |
|
1362 qed |
|
1363 next |
|
1364 fix n |
|
1365 show "\<exists>nba. Bk\<^bsup>nb\<^esup> @ Bk\<^bsup>n\<^esup> = Bk\<^bsup>nba\<^esup>" |
|
1366 apply(rule_tac x = "nb + n" in exI) |
|
1367 apply(simp add: exponent_def replicate_add) |
|
1368 done |
|
1369 qed |
|
1370 |
|
1371 lemma h_newcase: "\<And> M n. \<lbrakk>(haltP M n)\<rbrakk> \<Longrightarrow> |
|
1372 \<exists> na nb. (steps (Suc 0, Bk\<^bsup>x\<^esup>, Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na = (0, Bk\<^bsup>nb\<^esup>, [Oc]))" |
|
1373 proof - |
|
1374 fix M n x |
|
1375 assume "haltP M n" |
|
1376 hence " \<exists> na nb. (steps (Suc 0, [], Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na |
|
1377 = (0, Bk\<^bsup>nb\<^esup>, [Oc]))" |
|
1378 apply(erule_tac h_case) |
|
1379 done |
|
1380 from this obtain na nb where |
|
1381 cond1:"(steps (Suc 0, [], Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na |
|
1382 = (0, Bk\<^bsup>nb\<^esup>, [Oc]))" by blast |
|
1383 thus "\<exists> na nb. (steps (Suc 0, Bk\<^bsup>x\<^esup>, Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na = (0, Bk\<^bsup>nb\<^esup>, [Oc]))" |
|
1384 proof(rule_tac x = na in exI, case_tac "steps (Suc 0, Bk\<^bsup>x\<^esup>, Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na", simp) |
|
1385 fix a b c |
|
1386 assume cond2: "steps (Suc 0, Bk\<^bsup>x\<^esup>, Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na = (a, b, c)" |
|
1387 have "tinres (Bk\<^bsup>nb\<^esup>) b \<and> [Oc] = c \<and> 0 = a" |
|
1388 proof(rule_tac tinres_steps) |
|
1389 show "tinres [] (Bk\<^bsup>x\<^esup>)" |
|
1390 apply(simp add: tinres_def) |
|
1391 apply(auto) |
|
1392 done |
|
1393 next |
|
1394 show "(steps (Suc 0, [], Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na |
|
1395 = (0, Bk\<^bsup>nb\<^esup>, [Oc]))" |
|
1396 by(simp add: cond1) |
|
1397 next |
|
1398 show "steps (Suc 0, Bk\<^bsup>x\<^esup>, Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na = (a, b, c)" |
|
1399 by(simp add: cond2) |
|
1400 qed |
|
1401 thus "a = 0 \<and> (\<exists>nb. b = Bk\<^bsup>nb\<^esup>) \<and> c = [Oc]" |
|
1402 apply(auto simp: tinres_ex1) |
|
1403 done |
|
1404 qed |
|
1405 qed |
|
1406 |
|
1407 lemma nh_newcase: "\<And> M n. \<lbrakk>\<not> (haltP M n)\<rbrakk> \<Longrightarrow> |
|
1408 \<exists> na nb. (steps (Suc 0, Bk\<^bsup>x\<^esup>, Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na = (0, Bk\<^bsup>nb\<^esup>, [Oc, Oc]))" |
|
1409 proof - |
|
1410 fix M n |
|
1411 assume "\<not> haltP M n" |
|
1412 hence "\<exists> na nb. (steps (Suc 0, [], Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na |
|
1413 = (0, Bk\<^bsup>nb\<^esup>, [Oc, Oc]))" |
|
1414 apply(erule_tac nh_case) |
|
1415 done |
|
1416 from this obtain na nb where |
|
1417 cond1: "(steps (Suc 0, [], Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na |
|
1418 = (0, Bk\<^bsup>nb\<^esup>, [Oc, Oc]))" by blast |
|
1419 thus "\<exists> na nb. (steps (Suc 0, Bk\<^bsup>x\<^esup>, Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na = (0, Bk\<^bsup>nb\<^esup>, [Oc, Oc]))" |
|
1420 proof(rule_tac x = na in exI, case_tac "steps (Suc 0, Bk\<^bsup>x\<^esup>, Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na", simp) |
|
1421 fix a b c |
|
1422 assume cond2: "steps (Suc 0, Bk\<^bsup>x\<^esup>, Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na = (a, b, c)" |
|
1423 have "tinres (Bk\<^bsup>nb\<^esup>) b \<and> [Oc, Oc] = c \<and> 0 = a" |
|
1424 proof(rule_tac tinres_steps) |
|
1425 show "tinres [] (Bk\<^bsup>x\<^esup>)" |
|
1426 apply(simp add: tinres_def) |
|
1427 apply(auto) |
|
1428 done |
|
1429 next |
|
1430 show "(steps (Suc 0, [], Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na |
|
1431 = (0, Bk\<^bsup>nb\<^esup>, [Oc, Oc]))" |
|
1432 by(simp add: cond1) |
|
1433 next |
|
1434 show "steps (Suc 0, Bk\<^bsup>x\<^esup>, Oc\<^bsup>code M\<^esup> @ Bk # Oc\<^bsup>n\<^esup>) H na = (a, b, c)" |
|
1435 by(simp add: cond2) |
|
1436 qed |
|
1437 thus "a = 0 \<and> (\<exists>nb. b = Bk\<^bsup>nb\<^esup>) \<and> c = [Oc, Oc]" |
|
1438 apply(auto simp: tinres_ex1) |
|
1439 done |
|
1440 qed |
|
1441 qed |
|
1442 |
|
1443 lemma haltP_weaking: |
|
1444 "haltP (tcontra H) (code (tcontra H)) \<Longrightarrow> |
|
1445 \<exists>stp. isS0 (steps (Suc 0, [], Oc\<^bsup>code (tcontra H)\<^esup>) |
|
1446 ((tcopy |+| H) |+| dither) stp)" |
|
1447 apply(simp add: haltP_def, auto) |
|
1448 apply(rule_tac x = n in exI, simp add: isS0_def tcontra_def) |
|
1449 done |
|
1450 |
|
1451 lemma h_uh: "haltP (tcontra H) (code (tcontra H)) |
|
1452 \<Longrightarrow> \<not> haltP (tcontra H) (code (tcontra H))" |
|
1453 proof - |
|
1454 let ?cn = "code (tcontra H)" |
|
1455 let ?P1 = "\<lambda> tp. let (l, r) = tp in (l = [] \<and> |
|
1456 (r::block list) = Oc\<^bsup>(?cn)\<^esup>)" |
|
1457 let ?Q1 = "\<lambda> (l, r).(\<exists> nb. l = Bk\<^bsup>nb\<^esup> \<and> |
|
1458 r = Oc\<^bsup>(?cn)\<^esup> @ Bk # Oc\<^bsup>(?cn)\<^esup>)" |
|
1459 let ?P2 = ?Q1 |
|
1460 let ?Q2 = "\<lambda> (l, r). (\<exists> nd. l = Bk\<^bsup>nd \<^esup>\<and> r = [Oc])" |
|
1461 let ?P3 = "\<lambda> tp. False" |
|
1462 assume h: "haltP (tcontra H) (code (tcontra H))" |
|
1463 hence h1: "\<And> x. \<exists> na nb. steps (Suc 0, Bk\<^bsup>x\<^esup>, Oc\<^bsup>code (tcontra H)\<^esup> @ Bk # |
|
1464 Oc\<^bsup>code (tcontra H)\<^esup>) H na = (0, Bk\<^bsup>nb\<^esup>, [Oc])" |
|
1465 by(drule_tac x = x in h_newcase, simp) |
|
1466 have "?P1 \<turnstile>-> \<lambda> tp. (\<exists> stp tp'. steps (Suc 0, tp) (tcopy |+| H) stp = (0, tp') \<and> ?Q2 tp')" |
|
1467 proof(rule_tac turing_merge.t_merge_halt[of tcopy H "?P1" "?P2" "?P3" |
|
1468 "?P3" "?Q1" "?Q2"], auto simp: turing_merge_def) |
|
1469 show "\<exists>stp. case steps (Suc 0, [], Oc\<^bsup>?cn\<^esup>) tcopy stp of (s, tp') \<Rightarrow> |
|
1470 s = 0 \<and> (case tp' of (l, r) \<Rightarrow> (\<exists>nb. l = Bk\<^bsup>nb\<^esup>) \<and> r = Oc\<^bsup>?cn\<^esup> @ Bk # Oc\<^bsup>?cn\<^esup>)" |
|
1471 using tcopy_halt_rs[of "?cn"] |
|
1472 apply(auto) |
|
1473 apply(rule_tac x = stp in exI, auto simp: exponent_def) |
|
1474 done |
|
1475 next |
|
1476 fix nb |
|
1477 show "\<exists>stp. case steps (Suc 0, Bk\<^bsup>nb\<^esup>, Oc\<^bsup>code (tcontra H)\<^esup> @ Bk # Oc\<^bsup>code (tcontra H)\<^esup>) H stp of |
|
1478 (s, tp') \<Rightarrow> s = 0 \<and> (case tp' of (l, r) \<Rightarrow> (\<exists>nd. l = Bk\<^bsup>nd\<^esup>) \<and> r = [Oc])" |
|
1479 using h1[of nb] |
|
1480 apply(auto) |
|
1481 apply(rule_tac x = na in exI, auto) |
|
1482 done |
|
1483 next |
|
1484 show "\<lambda>(l, r). ((\<exists>nb. l = Bk\<^bsup>nb\<^esup>) \<and> r = Oc\<^bsup>code (tcontra H)\<^esup> @ Bk # Oc\<^bsup>code (tcontra H)\<^esup>) \<turnstile>-> |
|
1485 \<lambda>(l, r). ((\<exists>nb. l = Bk\<^bsup>nb\<^esup>) \<and> r = Oc\<^bsup>code (tcontra H)\<^esup> @ Bk # Oc\<^bsup>code (tcontra H)\<^esup>)" |
|
1486 apply(simp add: t_imply_def) |
|
1487 done |
|
1488 qed |
|
1489 hence "\<exists>stp tp'. steps (Suc 0, [], Oc\<^bsup>?cn\<^esup>) (tcopy |+| H) stp = (0, tp') \<and> |
|
1490 (case tp' of (l, r) \<Rightarrow> \<exists>nd. l = Bk\<^bsup>nd\<^esup> \<and> r = [Oc])" |
|
1491 apply(simp add: t_imply_def) |
|
1492 done |
|
1493 hence "?P1 \<turnstile>-> \<lambda> tp. \<not> (\<exists> stp. isS0 (steps (Suc 0, tp) ((tcopy |+| H) |+| dither) stp))" |
|
1494 proof(rule_tac turing_merge.t_merge_uhalt[of "tcopy |+| H" dither "?P1" "?P3" "?P3" |
|
1495 "?Q2" "?Q2" "?Q2"], simp add: turing_merge_def, auto) |
|
1496 fix stp nd |
|
1497 assume "steps (Suc 0, [], Oc\<^bsup>code (tcontra H)\<^esup>) (tcopy |+| H) stp = (0, Bk\<^bsup>nd\<^esup>, [Oc])" |
|
1498 thus "\<exists>stp. case steps (Suc 0, [], Oc\<^bsup>code (tcontra H)\<^esup>) (tcopy |+| H) stp of (s, tp') |
|
1499 \<Rightarrow> s = 0 \<and> (case tp' of (l, r) \<Rightarrow> (\<exists>nd. l = Bk\<^bsup>nd\<^esup>) \<and> r = [Oc])" |
|
1500 apply(rule_tac x = stp in exI, auto) |
|
1501 done |
|
1502 next |
|
1503 fix stp nd nda stpa |
|
1504 assume "isS0 (steps (Suc 0, Bk\<^bsup>nda\<^esup>, [Oc]) dither stpa)" |
|
1505 thus "False" |
|
1506 using dither_unhalt_rs[of nda] |
|
1507 apply auto |
|
1508 done |
|
1509 next |
|
1510 fix stp nd |
|
1511 show "\<lambda>(l, r). ((\<exists>nd. l = Bk\<^bsup>nd\<^esup>) \<and> r = [Oc]) \<turnstile>-> |
|
1512 \<lambda>(l, r). ((\<exists>nd. l = Bk\<^bsup>nd\<^esup>) \<and> r = [Oc])" |
|
1513 by (simp add: t_imply_def) |
|
1514 qed |
|
1515 thus "\<not> haltP (tcontra H) (code (tcontra H))" |
|
1516 apply(simp add: t_imply_def haltP_def tcontra_def, auto) |
|
1517 apply(erule_tac x = n in allE, simp add: isS0_def) |
|
1518 done |
|
1519 qed |
|
1520 |
|
1521 lemma uh_h: |
|
1522 assumes uh: "\<not> haltP (tcontra H) (code (tcontra H))" |
|
1523 shows "haltP (tcontra H) (code (tcontra H))" |
|
1524 proof - |
|
1525 let ?cn = "code (tcontra H)" |
|
1526 have h1: "\<And> x. \<exists> na nb. steps (Suc 0, Bk\<^bsup>x\<^esup>, Oc\<^bsup>?cn\<^esup> @ Bk # Oc\<^bsup>?cn\<^esup>) |
|
1527 H na = (0, Bk\<^bsup>nb\<^esup>, [Oc, Oc])" |
|
1528 using uh |
|
1529 by(drule_tac x = x in nh_newcase, simp) |
|
1530 let ?P1 = "\<lambda> tp. let (l, r) = tp in (l = [] \<and> |
|
1531 (r::block list) = Oc\<^bsup>(?cn)\<^esup>)" |
|
1532 let ?Q1 = "\<lambda> (l, r).(\<exists> na. l = Bk\<^bsup>na\<^esup> \<and> r = [Oc, Oc])" |
|
1533 let ?P2 = ?Q1 |
|
1534 let ?Q2 = ?Q1 |
|
1535 let ?P3 = "\<lambda> tp. False" |
|
1536 have "?P1 \<turnstile>-> \<lambda> tp. (\<exists> stp tp'. steps (Suc 0, tp) ((tcopy |+| H ) |+| dither) |
|
1537 stp = (0, tp') \<and> ?Q2 tp')" |
|
1538 proof(rule_tac turing_merge.t_merge_halt[of "tcopy |+| H" dither ?P1 ?P2 ?P3 ?P3 |
|
1539 ?Q1 ?Q2], auto simp: turing_merge_def) |
|
1540 show "\<exists>stp. case steps (Suc 0, [], Oc\<^bsup>code (tcontra H)\<^esup>) (tcopy |+| H) stp of (s, tp') \<Rightarrow> |
|
1541 |
|
1542 s = 0 \<and> (case tp' of (l, r) \<Rightarrow> (\<exists>na. l = Bk\<^bsup>na\<^esup>) \<and> r = [Oc, Oc])" |
|
1543 proof - |
|
1544 let ?Q1 = "\<lambda> (l, r).(\<exists> nb. l = Bk\<^bsup>nb\<^esup> \<and> r = Oc\<^bsup>(?cn)\<^esup> @ Bk # Oc\<^bsup>(?cn)\<^esup>)" |
|
1545 let ?P2 = "?Q1" |
|
1546 let ?Q2 = "\<lambda> (l, r).(\<exists> na. l = Bk\<^bsup>na\<^esup> \<and> r = [Oc, Oc])" |
|
1547 have "?P1 \<turnstile>-> \<lambda> tp. (\<exists> stp tp'. steps (Suc 0, tp) (tcopy |+| H ) |
|
1548 stp = (0, tp') \<and> ?Q2 tp')" |
|
1549 proof(rule_tac turing_merge.t_merge_halt[of tcopy H ?P1 ?P2 ?P3 ?P3 |
|
1550 ?Q1 ?Q2], auto simp: turing_merge_def) |
|
1551 show "\<exists>stp. case steps (Suc 0, [], Oc\<^bsup>code (tcontra H)\<^esup>) tcopy stp of (s, tp') \<Rightarrow> s = 0 |
|
1552 \<and> (case tp' of (l, r) \<Rightarrow> (\<exists>nb. l = Bk\<^bsup>nb\<^esup>) \<and> r = Oc\<^bsup>code (tcontra H)\<^esup> @ Bk # Oc\<^bsup>code (tcontra H)\<^esup>)" |
|
1553 using tcopy_halt_rs[of "?cn"] |
|
1554 apply(auto) |
|
1555 apply(rule_tac x = stp in exI, simp add: exponent_def) |
|
1556 done |
|
1557 next |
|
1558 fix nb |
|
1559 show "\<exists>stp. case steps (Suc 0, Bk\<^bsup>nb\<^esup>, Oc\<^bsup>code (tcontra H)\<^esup> @ Bk # Oc\<^bsup>code (tcontra H)\<^esup>) H stp of |
|
1560 (s, tp') \<Rightarrow> s = 0 \<and> (case tp' of (l, r) \<Rightarrow> (\<exists>na. l = Bk\<^bsup>na\<^esup>) \<and> r = [Oc, Oc])" |
|
1561 using h1[of nb] |
|
1562 apply(auto) |
|
1563 apply(rule_tac x = na in exI, auto) |
|
1564 done |
|
1565 next |
|
1566 show "\<lambda>(l, r). ((\<exists>nb. l = Bk\<^bsup>nb\<^esup>) \<and> r = Oc\<^bsup>code (tcontra H)\<^esup> @ Bk # Oc\<^bsup>code (tcontra H)\<^esup>) \<turnstile>-> |
|
1567 \<lambda>(l, r). ((\<exists>nb. l = Bk\<^bsup>nb\<^esup>) \<and> r = Oc\<^bsup>code (tcontra H)\<^esup> @ Bk # Oc\<^bsup>code (tcontra H)\<^esup>)" |
|
1568 by(simp add: t_imply_def) |
|
1569 qed |
|
1570 hence "(\<exists> stp tp'. steps (Suc 0, [], Oc\<^bsup>?cn\<^esup>) (tcopy |+| H ) stp = (0, tp') \<and> ?Q2 tp')" |
|
1571 apply(simp add: t_imply_def) |
|
1572 done |
|
1573 thus "?thesis" |
|
1574 apply(auto) |
|
1575 apply(rule_tac x = stp in exI, auto) |
|
1576 done |
|
1577 qed |
|
1578 next |
|
1579 fix na |
|
1580 show "\<exists>stp. case steps (Suc 0, Bk\<^bsup>na\<^esup>, [Oc, Oc]) dither stp of (s, tp') |
|
1581 \<Rightarrow> s = 0 \<and> (case tp' of (l, r) \<Rightarrow> (\<exists>na. l = Bk\<^bsup>na\<^esup>) \<and> r = [Oc, Oc])" |
|
1582 using dither_halt_rs[of na] |
|
1583 apply(auto) |
|
1584 apply(rule_tac x = stp in exI, auto) |
|
1585 done |
|
1586 next |
|
1587 show "\<lambda>(l, r). ((\<exists>na. l = Bk\<^bsup>na\<^esup>) \<and> r = [Oc, Oc]) \<turnstile>-> |
|
1588 (\<lambda>(l, r). (\<exists>na. l = Bk\<^bsup>na\<^esup>) \<and> r = [Oc, Oc])" |
|
1589 by (simp add: t_imply_def) |
|
1590 qed |
|
1591 hence "\<exists> stp tp'. steps (Suc 0, [], Oc\<^bsup>?cn\<^esup>) ((tcopy |+| H ) |+| dither) |
|
1592 stp = (0, tp') \<and> ?Q2 tp'" |
|
1593 apply(simp add: t_imply_def) |
|
1594 done |
|
1595 thus "haltP (tcontra H) (code (tcontra H))" |
|
1596 apply(auto simp: haltP_def tcontra_def) |
|
1597 apply(rule_tac x = stp in exI, |
|
1598 rule_tac x = na in exI, |
|
1599 rule_tac x = "Suc (Suc 0)" in exI, |
|
1600 rule_tac x = "0" in exI, simp add: exp_ind_def) |
|
1601 done |
|
1602 qed |
|
1603 |
|
1604 text {* |
|
1605 @{text "False"} is finally derived. |
|
1606 *} |
|
1607 |
|
1608 lemma "False" |
|
1609 using uh_h h_uh |
|
1610 by auto |
|
1611 end |
|
1612 |
|
1613 end |
|
1614 |
|