--- a/thys/UTM.thy Wed Feb 06 04:11:06 2013 +0000
+++ b/thys/UTM.thy Wed Feb 06 04:27:03 2013 +0000
@@ -1,5 +1,5 @@
theory UTM
-imports Main uncomputable recursive abacus UF GCD
+imports Main recursive abacus UF GCD turing_hoare
begin
section {* Wang coding of input arguments *}
@@ -24,7 +24,7 @@
\newcommand{\vsep}{5\baseheight}
The TM used to generate the Wang's code of input arguments is divided into three TMs
- executed sequentially, namely $prepare$, $mainwork$ and $adjust$¡£According to the
+ executed sequentially, namely $prepare$, $mainwork$ and $adjust$\<exclamdown>\<pounds>According to the
convention, start state of ever TM is fixed to state $1$ while the final state is
fixed to $0$.
@@ -509,21 +509,27 @@
where
"fourtimes_ly = layout_of abc_fourtimes"
-definition t_twice :: "tprog"
+definition t_twice_compile :: "instr list"
+where
+ "t_twice_compile= (tm_of abc_twice @ (shift (mopup 1) (length (tm_of abc_twice) div 2)))"
+
+definition t_twice :: "instr list"
where
- "t_twice = change_termi_state (tm_of (abc_twice) @ (tMp 1 (start_of twice_ly (length abc_twice) - Suc 0)))"
-
-definition t_fourtimes :: "tprog"
+ "t_twice = adjust t_twice_compile"
+
+definition t_fourtimes_compile :: "instr list"
+where
+ "t_fourtimes_compile= (tm_of abc_fourtimes @ (shift (mopup 1) (length (tm_of abc_fourtimes) div 2)))"
+
+definition t_fourtimes :: "instr list"
where
- "t_fourtimes = change_termi_state (tm_of (abc_fourtimes) @
- (tMp 1 (start_of fourtimes_ly (length abc_fourtimes) - Suc 0)))"
-
+ "t_fourtimes = adjust t_fourtimes_compile"
definition t_twice_len :: "nat"
where
"t_twice_len = length t_twice div 2"
-definition t_wcode_main_first_part:: "tprog"
+definition t_wcode_main_first_part:: "instr list"
where
"t_wcode_main_first_part \<equiv>
[(L, 1), (L, 2), (L, 7), (R, 3),
@@ -533,12 +539,12 @@
(R, 10), (W0, 9), (R, 10), (R, 11),
(W1, 12), (R, 11), (R, t_twice_len + 14), (L, 12)]"
-definition t_wcode_main :: "tprog"
+definition t_wcode_main :: "instr list"
where
- "t_wcode_main = (t_wcode_main_first_part @ tshift t_twice 12 @ [(L, 1), (L, 1)]
- @ tshift t_fourtimes (t_twice_len + 13) @ [(L, 1), (L, 1)])"
-
-fun bl_bin :: "block list \<Rightarrow> nat"
+ "t_wcode_main = (t_wcode_main_first_part @ shift t_twice 12 @ [(L, 1), (L, 1)]
+ @ shift t_fourtimes (t_twice_len + 13) @ [(L, 1), (L, 1)])"
+
+fun bl_bin :: "cell list \<Rightarrow> nat"
where
"bl_bin [] = 0"
| "bl_bin (Bk # xs) = 2 * bl_bin xs"
@@ -546,29 +552,29 @@
declare bl_bin.simps[simp del]
-type_synonym bin_inv_t = "block list \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
+type_synonym bin_inv_t = "cell list \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
fun wcode_before_double :: "bin_inv_t"
where
"wcode_before_double ires rs (l, r) =
- (\<exists> ln rn. l = Bk # Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires \<and>
- r = Oc\<^bsup>(Suc (Suc rs))\<^esup> @ Bk\<^bsup>rn \<^esup>)"
+ (\<exists> ln rn. l = Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and>
+ r = Oc\<up>((Suc (Suc rs))) @ Bk\<up>(rn ))"
declare wcode_before_double.simps[simp del]
fun wcode_after_double :: "bin_inv_t"
where
"wcode_after_double ires rs (l, r) =
- (\<exists> ln rn. l = Bk # Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires \<and>
- r = Oc\<^bsup>Suc (Suc (Suc 2*rs))\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ (\<exists> ln rn. l = Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and>
+ r = Oc\<up>(Suc (Suc (Suc 2*rs))) @ Bk\<up>(rn))"
declare wcode_after_double.simps[simp del]
fun wcode_on_left_moving_1_B :: "bin_inv_t"
where
"wcode_on_left_moving_1_B ires rs (l, r) =
- (\<exists> ml mr rn. l = Bk\<^bsup>ml\<^esup> @ Oc # Oc # ires \<and>
- r = Bk\<^bsup>mr\<^esup> @ Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ (\<exists> ml mr rn. l = Bk\<up>(ml) @ Oc # Oc # ires \<and>
+ r = Bk\<up>(mr) @ Oc\<up>(Suc rs) @ Bk\<up>(rn) \<and>
ml + mr > Suc 0 \<and> mr > 0)"
declare wcode_on_left_moving_1_B.simps[simp del]
@@ -578,7 +584,7 @@
"wcode_on_left_moving_1_O ires rs (l, r) =
(\<exists> ln rn.
l = Oc # ires \<and>
- r = Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ r = Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
declare wcode_on_left_moving_1_O.simps[simp del]
@@ -593,13 +599,13 @@
where
"wcode_on_checking_1 ires rs (l, r) =
(\<exists> ln rn. l = ires \<and>
- r = Oc # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ r = Oc # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
fun wcode_erase1 :: "bin_inv_t"
where
"wcode_erase1 ires rs (l, r) =
(\<exists> ln rn. l = Oc # ires \<and>
- tl r = Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ tl r = Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
declare wcode_erase1.simps [simp del]
@@ -607,8 +613,8 @@
where
"wcode_on_right_moving_1 ires rs (l, r) =
(\<exists> ml mr rn.
- l = Bk\<^bsup>ml\<^esup> @ Oc # ires \<and>
- r = Bk\<^bsup>mr\<^esup> @ Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ l = Bk\<up>(ml) @ Oc # ires \<and>
+ r = Bk\<up>(mr) @ Oc\<up>(Suc rs) @ Bk\<up>(rn) \<and>
ml + mr > Suc 0)"
declare wcode_on_right_moving_1.simps [simp del]
@@ -619,8 +625,8 @@
where
"wcode_goon_right_moving_1 ires rs (l, r) =
(\<exists> ml mr ln rn.
- l = Oc\<^bsup>ml\<^esup> @ Bk # Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires \<and>
- r = Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ l = Oc\<up>(ml) @ Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and>
+ r = Oc\<up>(mr) @ Bk\<up>(rn) \<and>
ml + mr = Suc rs)"
declare wcode_goon_right_moving_1.simps[simp del]
@@ -628,8 +634,8 @@
fun wcode_backto_standard_pos_B :: "bin_inv_t"
where
"wcode_backto_standard_pos_B ires rs (l, r) =
- (\<exists> ln rn. l = Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires \<and>
- r = Bk # Oc\<^bsup>(Suc (Suc rs))\<^esup> @ Bk\<^bsup>rn \<^esup>)"
+ (\<exists> ln rn. l = Bk # Bk\<up>(ln) @ Oc # ires \<and>
+ r = Bk # Oc\<up>((Suc (Suc rs))) @ Bk\<up>(rn ))"
declare wcode_backto_standard_pos_B.simps[simp del]
@@ -637,8 +643,8 @@
where
"wcode_backto_standard_pos_O ires rs (l, r) =
(\<exists> ml mr ln rn.
- l = Oc\<^bsup>ml\<^esup> @ Bk # Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires \<and>
- r = Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ l = Oc\<up>(ml) @ Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and>
+ r = Oc\<up>(mr) @ Bk\<up>(rn) \<and>
ml + mr = Suc (Suc rs) \<and> mr > 0)"
declare wcode_backto_standard_pos_O.simps[simp del]
@@ -651,13 +657,11 @@
declare wcode_backto_standard_pos.simps[simp del]
lemma [simp]: "<0::nat> = [Oc]"
-apply(simp add: tape_of_nat_abv exponent_def tape_of_nat_list.simps)
+apply(simp add: tape_of_nat_abv tape_of_nat_list.simps)
done
lemma tape_of_Suc_nat: "<Suc (a ::nat)> = replicate a Oc @ [Oc, Oc]"
-apply(simp add: tape_of_nat_abv exp_ind tape_of_nat_list.simps)
-apply(simp only: exp_ind_def[THEN sym])
-apply(simp only: exp_ind, simp, simp add: exponent_def)
+apply(simp only: tape_of_nat_abv exp_ind, simp)
done
lemma [simp]: "length (<a::nat>) = Suc a"
@@ -665,8 +669,8 @@
done
lemma [simp]: "<[a::nat]> = <a>"
-apply(simp add: tape_of_nat_abv tape_of_nl_abv exponent_def
- tape_of_nat_list.simps)
+apply(simp add: tape_of_nat_abv tape_of_nl_abv
+ tape_of_nat_list.simps)
done
lemma bin_wc_eq: "bl_bin xs = bl2wc xs"
@@ -683,27 +687,30 @@
done
qed
-declare exp_def[simp del]
-
lemma bl_bin_nat_Suc:
"bl_bin (<Suc a>) = bl_bin (<a>) + 2^(Suc a)"
-apply(simp add: tape_of_nat_abv bin_wc_eq)
-apply(simp add: bl2wc.simps)
-done
-lemma [simp]: " rev (a\<^bsup>aa\<^esup>) = a\<^bsup>aa\<^esup>"
-apply(simp add: exponent_def)
-done
-
-declare tape_of_nl_abv_cons[simp del]
+apply(simp add: tape_of_nat_abv bl_bin.simps)
+apply(induct a, auto simp: bl_bin.simps)
+done
+
+lemma [simp]: " rev (a\<up>(aa)) = a\<up>(aa)"
+apply(simp)
+done
+
+lemma tape_of_nl_append_one: "lm \<noteq> [] \<Longrightarrow> <lm @ [a]> = <lm> @ Bk # Oc\<up>Suc a"
+apply(induct lm, auto simp: tape_of_nl_cons split:if_splits)
+done
lemma tape_of_nl_rev: "rev (<lm::nat list>) = (<rev lm>)"
-apply(induct lm rule: list_tl_induct, simp)
-apply(case_tac "list = []", simp add: tape_of_nl_abv tape_of_nat_list.simps)
-apply(simp add: tape_of_nat_list_butlast_last tape_of_nl_abv_cons)
-done
-lemma [simp]: "a\<^bsup>Suc 0\<^esup> = [a]"
-by(simp add: exp_def)
-lemma tape_of_nl_cons_app1: "(<a # xs @ [b]>) = (Oc\<^bsup>Suc a\<^esup> @ Bk # (<xs@ [b]>))"
+apply(induct lm, simp, auto)
+apply(auto simp: tape_of_nl_cons tape_of_nl_append_one split: if_splits)
+apply(simp add: exp_ind[THEN sym])
+done
+
+lemma [simp]: "a\<up>(Suc 0) = [a]"
+by(simp)
+
+lemma tape_of_nl_cons_app1: "(<a # xs @ [b]>) = (Oc\<up>(Suc a) @ Bk # (<xs@ [b]>))"
apply(case_tac xs, simp add: tape_of_nl_abv tape_of_nat_list.simps)
apply(simp add: tape_of_nl_abv tape_of_nat_list.simps)
done
@@ -716,26 +723,27 @@
apply(simp add: bl2nat_cons_bk bl2wc.simps)
done
-lemma tape_of_nat[simp]: "(<a::nat>) = Oc\<^bsup>Suc a\<^esup>"
+lemma tape_of_nat[simp]: "(<a::nat>) = Oc\<up>(Suc a)"
apply(simp add: tape_of_nat_abv)
done
-lemma tape_of_nl_cons_app2: "(<c # xs @ [b]>) = (<c # xs> @ Bk # Oc\<^bsup>Suc b\<^esup>)"
+
+lemma tape_of_nl_cons_app2: "(<c # xs @ [b]>) = (<c # xs> @ Bk # Oc\<up>(Suc b))"
proof(induct "length xs" arbitrary: xs c,
simp add: tape_of_nl_abv tape_of_nat_list.simps)
fix x xs c
assume ind: "\<And>xs c. x = length xs \<Longrightarrow> <c # xs @ [b]> =
- <c # xs> @ Bk # Oc\<^bsup>Suc b\<^esup>"
+ <c # xs> @ Bk # Oc\<up>(Suc b)"
and h: "Suc x = length (xs::nat list)"
- show "<c # xs @ [b]> = <c # xs> @ Bk # Oc\<^bsup>Suc b\<^esup>"
+ show "<c # xs @ [b]> = <c # xs> @ Bk # Oc\<up>(Suc b)"
proof(case_tac xs, simp add: tape_of_nl_abv tape_of_nat_list.simps)
fix a list
assume g: "xs = a # list"
- hence k: "<a # list @ [b]> = <a # list> @ Bk # Oc\<^bsup>Suc b\<^esup>"
+ hence k: "<a # list @ [b]> = <a # list> @ Bk # Oc\<up>(Suc b)"
apply(rule_tac ind)
using h
apply(simp)
done
- from g and k show "<c # xs @ [b]> = <c # xs> @ Bk # Oc\<^bsup>Suc b\<^esup>"
+ from g and k show "<c # xs @ [b]> = <c # xs> @ Bk # Oc\<up>(Suc b)"
apply(simp add: tape_of_nl_abv tape_of_nat_list.simps)
done
qed
@@ -745,21 +753,24 @@
apply(simp add: tape_of_nl_abv tape_of_nat_list.simps)
done
-lemma [simp]: "bl_bin (Oc\<^bsup>Suc aa\<^esup> @ Bk # tape_of_nat_list (a # lista) @ [Bk, Oc]) =
- bl_bin (Oc\<^bsup>Suc aa\<^esup> @ Bk # tape_of_nat_list (a # lista)) +
- 2* 2^(length (Oc\<^bsup>Suc aa\<^esup> @ Bk # tape_of_nat_list (a # lista)))"
-using bl_bin_bk_oc[of "Oc\<^bsup>Suc aa\<^esup> @ Bk # tape_of_nat_list (a # lista)"]
+lemma [simp]: "bl_bin (Oc\<up>(Suc aa) @ Bk # tape_of_nat_list (a # lista) @ [Bk, Oc]) =
+ bl_bin (Oc\<up>(Suc aa) @ Bk # tape_of_nat_list (a # lista)) +
+ 2* 2^(length (Oc\<up>(Suc aa) @ Bk # tape_of_nat_list (a # lista)))"
+using bl_bin_bk_oc[of "Oc\<up>(Suc aa) @ Bk # tape_of_nat_list (a # lista)"]
apply(simp)
done
+declare replicate_Suc[simp del]
+
lemma [simp]:
"bl_bin (<aa # list>) + (4 * rs + 4) * 2 ^ (length (<aa # list>) - Suc 0)
- = bl_bin (Oc\<^bsup>Suc aa\<^esup> @ Bk # <list @ [0]>) + rs * (2 * 2 ^ (aa + length (<list @ [0]>)))"
-apply(case_tac "list", simp add: add_mult_distrib, simp)
+ = bl_bin (Oc\<up>(Suc aa) @ Bk # <list @ [0]>) + rs * (2 * 2 ^ (aa + length (<list @ [0]>)))"
+
+apply(case_tac "list", simp add: add_mult_distrib)
apply(simp add: tape_of_nl_cons_app2 add_mult_distrib)
apply(simp add: tape_of_nl_abv tape_of_nat_list.simps)
done
-
+
lemma tape_of_nl_app_Suc: "((<list @ [Suc ab]>)) = (<list @ [ab]>) @ [Oc]"
apply(induct list)
apply(simp add: tape_of_nl_abv tape_of_nat_list.simps exp_ind)
@@ -767,17 +778,17 @@
apply(simp_all add:tape_of_nl_abv tape_of_nat_list.simps exp_ind)
done
-lemma [simp]: "bl_bin (Oc # Oc\<^bsup>aa\<^esup> @ Bk # <list @ [ab]> @ [Oc])
- = bl_bin (Oc # Oc\<^bsup>aa\<^esup> @ Bk # <list @ [ab]>) +
- 2^(length (Oc # Oc\<^bsup>aa\<^esup> @ Bk # <list @ [ab]>))"
+lemma [simp]: "bl_bin (Oc # Oc\<up>(aa) @ Bk # <list @ [ab]> @ [Oc])
+ = bl_bin (Oc # Oc\<up>(aa) @ Bk # <list @ [ab]>) +
+ 2^(length (Oc # Oc\<up>(aa) @ Bk # <list @ [ab]>))"
apply(simp add: bin_wc_eq)
apply(simp add: bl2nat_cons_oc bl2wc.simps)
-using bl2nat_cons_oc[of "Oc # Oc\<^bsup>aa\<^esup> @ Bk # <list @ [ab]>"]
+using bl2nat_cons_oc[of "Oc # Oc\<up>(aa) @ Bk # <list @ [ab]>"]
apply(simp)
done
-lemma [simp]: "bl_bin (Oc # Oc\<^bsup>aa\<^esup> @ Bk # <list @ [ab]>) + (4 * 2 ^ (aa + length (<list @ [ab]>)) +
+lemma [simp]: "bl_bin (Oc # Oc\<up>(aa) @ Bk # <list @ [ab]>) + (4 * 2 ^ (aa + length (<list @ [ab]>)) +
4 * (rs * 2 ^ (aa + length (<list @ [ab]>)))) =
- bl_bin (Oc # Oc\<^bsup>aa\<^esup> @ Bk # <list @ [Suc ab]>) +
+ bl_bin (Oc # Oc\<up>(aa) @ Bk # <list @ [Suc ab]>) +
rs * (2 * 2 ^ (aa + length (<list @ [Suc ab]>)))"
apply(simp add: tape_of_nl_app_Suc)
done
@@ -798,12 +809,12 @@
declare wcode_double_case_inv.simps[simp del]
-fun wcode_double_case_state :: "t_conf \<Rightarrow> nat"
+fun wcode_double_case_state :: "config \<Rightarrow> nat"
where
"wcode_double_case_state (st, l, r) =
13 - st"
-fun wcode_double_case_step :: "t_conf \<Rightarrow> nat"
+fun wcode_double_case_step :: "config \<Rightarrow> nat"
where
"wcode_double_case_step (st, l, r) =
(if st = Suc 0 then (length l)
@@ -815,13 +826,13 @@
else if st = 6 then (length l)
else 0)"
-fun wcode_double_case_measure :: "t_conf \<Rightarrow> nat \<times> nat"
+fun wcode_double_case_measure :: "config \<Rightarrow> nat \<times> nat"
where
"wcode_double_case_measure (st, l, r) =
(wcode_double_case_state (st, l, r),
wcode_double_case_step (st, l, r))"
-definition wcode_double_case_le :: "(t_conf \<times> t_conf) set"
+definition wcode_double_case_le :: "(config \<times> config) set"
where "wcode_double_case_le \<equiv> (inv_image lex_pair wcode_double_case_measure)"
lemma [intro]: "wf lex_pair"
@@ -857,42 +868,49 @@
done
lemma [simp]: "fetch t_wcode_main 4 Bk = (R, 4)"
-apply(simp add: t_wcode_main_def t_wcode_main_first_part_def
- fetch.simps nth_of.simps)
+apply(subgoal_tac "4 = Suc 3")
+apply(simp only: t_wcode_main_def t_wcode_main_first_part_def
+ fetch.simps nth_of.simps, auto)
done
lemma [simp]: "fetch t_wcode_main 4 Oc = (R, 5)"
-apply(simp add: t_wcode_main_def t_wcode_main_first_part_def
- fetch.simps nth_of.simps)
+apply(subgoal_tac "4 = Suc 3")
+apply(simp only: t_wcode_main_def t_wcode_main_first_part_def
+ fetch.simps nth_of.simps, auto)
done
lemma [simp]: "fetch t_wcode_main 5 Oc = (R, 5)"
-apply(simp add: t_wcode_main_def t_wcode_main_first_part_def
- fetch.simps nth_of.simps)
+apply(subgoal_tac "5 = Suc 4")
+apply(simp only: t_wcode_main_def t_wcode_main_first_part_def
+ fetch.simps nth_of.simps, auto)
done
lemma [simp]: "fetch t_wcode_main 5 Bk = (W1, 6)"
-apply(simp add: t_wcode_main_def t_wcode_main_first_part_def
- fetch.simps nth_of.simps)
+apply(subgoal_tac "5 = Suc 4")
+apply(simp only: t_wcode_main_def t_wcode_main_first_part_def
+ fetch.simps nth_of.simps, auto)
done
lemma [simp]: "fetch t_wcode_main 6 Bk = (R, 13)"
-apply(simp add: t_wcode_main_def t_wcode_main_first_part_def
- fetch.simps nth_of.simps)
-done
-
+apply(subgoal_tac "6 = Suc 5")
+apply(simp only: t_wcode_main_def t_wcode_main_first_part_def
+ fetch.simps nth_of.simps, auto)
+done
+
lemma [simp]: "fetch t_wcode_main 6 Oc = (L, 6)"
-apply(simp add: t_wcode_main_def t_wcode_main_first_part_def
- fetch.simps nth_of.simps)
-done
-lemma [elim]: "Bk\<^bsup>mr\<^esup> = [] \<Longrightarrow> mr = 0"
-apply(case_tac mr, auto simp: exponent_def)
+apply(subgoal_tac "6 = Suc 5")
+apply(simp only: t_wcode_main_def t_wcode_main_first_part_def
+ fetch.simps nth_of.simps, auto)
+done
+
+lemma [elim]: "Bk\<up>(mr) = [] \<Longrightarrow> mr = 0"
+apply(case_tac mr, auto)
done
lemma [simp]: "wcode_on_left_moving_1 ires rs (b, []) = False"
apply(simp add: wcode_on_left_moving_1.simps wcode_on_left_moving_1_B.simps
- wcode_on_left_moving_1_O.simps, auto)
-done
+ wcode_on_left_moving_1_O.simps)
+done
declare wcode_on_checking_1.simps[simp del]
@@ -921,11 +939,12 @@
apply(case_tac mr, simp, case_tac nat, simp, simp add: exp_ind)
apply(rule_tac disjI1)
apply(rule_tac x = nat in exI, rule_tac x = "Suc mr" in exI, rule_tac x = rn in exI,
- simp add: exp_ind_def)
+ simp, simp add: replicate_Suc)
apply(erule_tac exE)+
apply(simp)
done
+declare replicate_Suc[simp]
lemma [elim]:
"\<lbrakk>wcode_on_left_moving_1 ires rs (b, Oc # list); tl b = aa \<and> hd b # Oc # list = ba\<rbrakk>
@@ -933,10 +952,8 @@
apply(simp only: wcode_double_case_inv_simps)
apply(erule_tac disjE)
apply(erule_tac [!] exE)+
-apply(case_tac mr, simp, simp add: exp_ind_def)
-apply(rule_tac x = ln in exI, rule_tac x = rn in exI, simp)
-done
-
+apply(case_tac mr, simp, auto)
+done
lemma [simp]: "wcode_on_checking_1 ires rs (b, []) = False"
apply(auto simp: wcode_double_case_inv_simps)
@@ -967,11 +984,11 @@
done
lemma [simp]: "wcode_on_right_moving_1 ires rs (b, []) = False"
-apply(simp add: wcode_double_case_inv_simps exp_ind_def)
+apply(simp add: wcode_double_case_inv_simps)
done
lemma [simp]: "wcode_on_right_moving_1 ires rs (b, []) = False"
-apply(simp add: wcode_double_case_inv_simps exp_ind_def)
+apply(simp add: wcode_double_case_inv_simps)
done
lemma [elim]: "\<lbrakk>wcode_on_right_moving_1 ires rs (b, Bk # ba); Bk # b = aa \<and> list = b\<rbrakk> \<Longrightarrow>
@@ -980,8 +997,8 @@
apply(erule_tac exE)+
apply(rule_tac x = "Suc ml" in exI, rule_tac x = "mr - Suc 0" in exI,
rule_tac x = rn in exI)
-apply(simp add: exp_ind_def)
-apply(case_tac mr, simp, simp add: exp_ind_def)
+apply(simp)
+apply(case_tac mr, simp, simp)
done
lemma [elim]:
@@ -991,14 +1008,13 @@
apply(erule_tac exE)+
apply(rule_tac x = "Suc 0" in exI, rule_tac x = "rs" in exI,
rule_tac x = "ml - Suc (Suc 0)" in exI, rule_tac x = rn in exI)
-apply(case_tac mr, simp_all add: exp_ind_def)
+apply(case_tac mr, simp_all)
apply(case_tac ml, simp, case_tac nat, simp, simp)
-apply(simp add: exp_ind_def)
done
lemma [simp]:
"wcode_on_right_moving_1 ires rs (b, []) \<Longrightarrow> False"
-apply(simp add: wcode_double_case_inv_simps exponent_def)
+apply(simp add: wcode_double_case_inv_simps)
done
lemma [elim]: "\<lbrakk>wcode_erase1 ires rs (b, Bk # ba); Bk # b = aa \<and> list = ba; c = Bk # ba\<rbrakk>
@@ -1006,7 +1022,7 @@
apply(simp only: wcode_double_case_inv_simps)
apply(erule_tac exE)+
apply(rule_tac x = "Suc 0" in exI, rule_tac x = "Suc (Suc ln)" in exI,
- rule_tac x = rn in exI, simp add: exp_ind)
+ rule_tac x = rn in exI, simp add: exp_ind del: replicate_Suc)
done
lemma [elim]: "\<lbrakk>wcode_erase1 ires rs (aa, Oc # list); b = aa \<and> Bk # list = ba\<rbrakk> \<Longrightarrow>
@@ -1024,7 +1040,6 @@
apply(simp only:wcode_backto_standard_pos_O.simps)
apply(rule_tac x = ml in exI, rule_tac x = "Suc 0" in exI, rule_tac x = ln in exI,
rule_tac x = rn in exI, simp)
-apply(case_tac mr, simp_all add: exponent_def)
done
lemma [elim]:
@@ -1036,7 +1051,7 @@
apply(simp only:wcode_backto_standard_pos_O.simps)
apply(rule_tac x = ml in exI, rule_tac x = "Suc 0" in exI, rule_tac x = ln in exI,
rule_tac x = "rn - Suc 0" in exI, simp)
-apply(case_tac mr, simp, case_tac rn, simp, simp_all add: exp_ind_def)
+apply(case_tac mr, simp, case_tac rn, simp, simp_all)
done
lemma [elim]: "\<lbrakk>wcode_goon_right_moving_1 ires rs (b, Oc # ba); Oc # b = aa \<and> list = ba\<rbrakk>
@@ -1045,14 +1060,13 @@
apply(erule_tac exE)+
apply(rule_tac x = "Suc ml" in exI, rule_tac x = "mr - Suc 0" in exI,
rule_tac x = ln in exI, rule_tac x = rn in exI)
-apply(simp add: exp_ind_def)
-apply(case_tac mr, simp, case_tac rn, simp_all add: exp_ind_def)
+apply(simp)
+apply(case_tac mr, simp, case_tac rn, simp_all)
done
lemma [elim]: "\<lbrakk>wcode_backto_standard_pos ires rs (b, []); Bk # b = aa\<rbrakk> \<Longrightarrow> False"
apply(auto simp: wcode_double_case_inv_simps wcode_backto_standard_pos_O.simps
wcode_backto_standard_pos_B.simps)
-apply(case_tac mr, simp_all add: exp_ind_def)
done
lemma [elim]: "\<lbrakk>wcode_backto_standard_pos ires rs (b, Bk # ba); Bk # b = aa \<and> list = ba\<rbrakk>
@@ -1063,7 +1077,7 @@
apply(erule_tac exE)+
apply(rule_tac x = ln in exI, rule_tac x = rn in exI, simp)
apply(auto)
-apply(case_tac [!] mr, simp_all add: exp_ind_def)
+apply(case_tac [!] mr, simp_all)
done
lemma [simp]: "wcode_backto_standard_pos ires rs ([], Oc # list) = False"
@@ -1074,7 +1088,6 @@
lemma [simp]: "wcode_backto_standard_pos ires rs (b, []) = False"
apply(auto simp: wcode_backto_standard_pos.simps wcode_backto_standard_pos_B.simps
wcode_backto_standard_pos_O.simps)
-apply(case_tac mr, simp, simp add: exp_ind_def)
done
lemma [elim]: "\<lbrakk>wcode_backto_standard_pos ires rs (b, Oc # list); tl b = aa; hd b # Oc # list = ba\<rbrakk>
@@ -1090,19 +1103,18 @@
apply(rule_tac disjI2)
apply(rule_tac x = nat in exI, rule_tac x = "Suc mr" in exI, rule_tac x = ln in exI,
rule_tac x = rn in exI, simp)
-apply(simp add: exp_ind_def)
-done
-
-declare new_tape.simps[simp del] nth_of.simps[simp del] fetch.simps[simp del]
+done
+
+declare nth_of.simps[simp del] fetch.simps[simp del]
lemma wcode_double_case_first_correctness:
"let P = (\<lambda> (st, l, r). st = 13) in
let Q = (\<lambda> (st, l, r). wcode_double_case_inv st ires rs (l, r)) in
- let f = (\<lambda> stp. steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Oc # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp) in
+ let f = (\<lambda> stp. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp) in
\<exists> n .P (f n) \<and> Q (f (n::nat))"
proof -
let ?P = "(\<lambda> (st, l, r). st = 13)"
let ?Q = "(\<lambda> (st, l, r). wcode_double_case_inv st ires rs (l, r))"
- let ?f = "(\<lambda> stp. steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Oc # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp)"
+ let ?f = "(\<lambda> stp. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp)"
have "\<exists> n. ?P (?f n) \<and> ?Q (?f (n::nat))"
proof(rule_tac halt_lemma2)
show "wf wcode_double_case_le"
@@ -1110,16 +1122,16 @@
next
show "\<forall> na. \<not> ?P (?f na) \<and> ?Q (?f na) \<longrightarrow>
?Q (?f (Suc na)) \<and> (?f (Suc na), ?f na) \<in> wcode_double_case_le"
- proof(rule_tac allI, case_tac "?f na", simp add: tstep_red)
+ proof(rule_tac allI, case_tac "?f na", simp add: step_red)
fix na a b c
show "a \<noteq> 13 \<and> wcode_double_case_inv a ires rs (b, c) \<longrightarrow>
- (case tstep (a, b, c) t_wcode_main of (st, x) \<Rightarrow>
+ (case step0 (a, b, c) t_wcode_main of (st, x) \<Rightarrow>
wcode_double_case_inv st ires rs x) \<and>
- (tstep (a, b, c) t_wcode_main, a, b, c) \<in> wcode_double_case_le"
+ (step0 (a, b, c) t_wcode_main, a, b, c) \<in> wcode_double_case_le"
apply(rule_tac impI, simp add: wcode_double_case_inv.simps)
- apply(auto split: if_splits simp: tstep.simps,
- case_tac [!] c, simp_all, case_tac [!] "(c::block list)!0")
- apply(simp_all add: new_tape.simps wcode_double_case_inv.simps wcode_double_case_le_def
+ apply(auto split: if_splits simp: step.simps,
+ case_tac [!] c, simp_all, case_tac [!] "(c::cell list)!0")
+ apply(simp_all add: wcode_double_case_inv.simps wcode_double_case_le_def
lex_pair_def)
apply(auto split: if_splits)
done
@@ -1130,9 +1142,8 @@
wcode_on_left_moving_1.simps
wcode_on_left_moving_1_B.simps)
apply(rule_tac disjI1)
- apply(rule_tac x = "Suc m" in exI, simp add: exp_ind_def)
- apply(rule_tac x = "Suc 0" in exI, simp add: exp_ind_def)
- apply(auto)
+ apply(rule_tac x = "Suc m" in exI, simp)
+ apply(rule_tac x = "Suc 0" in exI, simp)
done
next
show "\<not> ?P (?f 0)"
@@ -1141,101 +1152,39 @@
qed
thus "let P = \<lambda>(st, l, r). st = 13;
Q = \<lambda>(st, l, r). wcode_double_case_inv st ires rs (l, r);
- f = steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Oc # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main
+ f = steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main
in \<exists>n. P (f n) \<and> Q (f n)"
apply(simp add: Let_def)
done
qed
-lemma [elim]: "t_ncorrect tp
- \<Longrightarrow> t_ncorrect (tshift tp a)"
-apply(simp add: t_ncorrect.simps shift_length)
-done
-
-lemma tshift_fetch: "\<lbrakk> fetch tp a b = (aa, st'); 0 < st'\<rbrakk>
- \<Longrightarrow> fetch (tshift tp (length tp1 div 2)) a b
- = (aa, st' + length tp1 div 2)"
-apply(subgoal_tac "a > 0")
-apply(auto simp: fetch.simps nth_of.simps shift_length nth_map
- tshift.simps split: block.splits if_splits)
-done
-
-lemma t_steps_steps_eq: "\<lbrakk>steps (st, l, r) tp stp = (st', l', r');
- 0 < st';
- 0 < st \<and> st \<le> length tp div 2;
- t_ncorrect tp1;
- t_ncorrect tp\<rbrakk>
- \<Longrightarrow> t_steps (st + length tp1 div 2, l, r) (tshift tp (length tp1 div 2),
- length tp1 div 2) stp
- = (st' + length tp1 div 2, l', r')"
-apply(induct stp arbitrary: st' l' r', simp add: steps.simps t_steps.simps,
- simp add: tstep_red stepn)
-apply(case_tac "(steps (st, l, r) tp stp)", simp)
+lemma tm_append_shift_append_steps:
+"\<lbrakk>steps0 (st, l, r) tp stp = (st', l', r');
+ 0 < st';
+ length tp1 mod 2 = 0
+ \<rbrakk>
+ \<Longrightarrow> steps0 (st + length tp1 div 2, l, r) (tp1 @ shift tp (length tp1 div 2) @ tp2) stp
+ = (st' + length tp1 div 2, l', r')"
proof -
- fix stp st' l' r' a b c
- assume ind: "\<And>st' l' r'.
- \<lbrakk>a = st' \<and> b = l' \<and> c = r'; 0 < st'\<rbrakk>
- \<Longrightarrow> t_steps (st + length tp1 div 2, l, r)
- (tshift tp (length tp1 div 2), length tp1 div 2) stp =
- (st' + length tp1 div 2, l', r')"
- and h: "tstep (a, b, c) tp = (st', l', r')" "0 < st'" "t_ncorrect tp1" "t_ncorrect tp"
- have k: "t_steps (st + length tp1 div 2, l, r) (tshift tp (length tp1 div 2),
- length tp1 div 2) stp = (a + length tp1 div 2, b, c)"
- apply(rule_tac ind, simp)
+ assume h:
+ "steps0 (st, l, r) tp stp = (st', l', r')"
+ "0 < st'"
+ "length tp1 mod 2 = 0 "
+ from h have
+ "steps (st + length tp1 div 2, l, r) (tp1 @ shift tp (length tp1 div 2), 0) stp =
+ (st' + length tp1 div 2, l', r')"
+ by(rule_tac tm_append_second_steps_eq, simp_all)
+ then have "steps (st + length tp1 div 2, l, r) ((tp1 @ shift tp (length tp1 div 2)) @ tp2, 0) stp =
+ (st' + length tp1 div 2, l', r')"
using h
- apply(case_tac a, simp_all add: tstep.simps fetch.simps)
+ apply(rule_tac tm_append_first_steps_eq, simp_all)
done
- from h and this show "t_step (t_steps (st + length tp1 div 2, l, r) (tshift tp (length tp1 div 2), length tp1 div 2) stp)
- (tshift tp (length tp1 div 2), length tp1 div 2) =
- (st' + length tp1 div 2, l', r')"
- apply(simp add: k)
- apply(simp add: tstep.simps t_step.simps)
- apply(case_tac "fetch tp a (case c of [] \<Rightarrow> Bk | x # xs \<Rightarrow> x)", simp)
- apply(subgoal_tac "fetch (tshift tp (length tp1 div 2)) a
- (case c of [] \<Rightarrow> Bk | x # xs \<Rightarrow> x) = (aa, st' + length tp1 div 2)", simp)
- apply(simp add: tshift_fetch)
- done
+ thus "?thesis"
+ by simp
qed
-lemma t_tshift_lemma: "\<lbrakk> steps (st, l, r) tp stp = (st', l', r');
- st' \<noteq> 0;
- stp > 0;
- 0 < st \<and> st \<le> length tp div 2;
- t_ncorrect tp1;
- t_ncorrect tp;
- t_ncorrect tp2
- \<rbrakk>
- \<Longrightarrow> \<exists> stp>0. steps (st + length tp1 div 2, l, r) (tp1 @ tshift tp (length tp1 div 2) @ tp2) stp
- = (st' + length tp1 div 2, l', r')"
-proof -
- assume h: "steps (st, l, r) tp stp = (st', l', r')"
- "st' \<noteq> 0" "stp > 0"
- "0 < st \<and> st \<le> length tp div 2"
- "t_ncorrect tp1"
- "t_ncorrect tp"
- "t_ncorrect tp2"
- from h have
- "\<exists>stp>0. t_steps (st + length tp1 div 2, l, r) (tp1 @ tshift tp (length tp1 div 2) @ tp2, 0) stp =
- (st' + length tp1 div 2, l', r')"
- apply(rule_tac stp = stp in turing_shift, simp_all add: shift_length)
- apply(simp add: t_steps_steps_eq)
- apply(simp add: t_ncorrect.simps shift_length)
- done
- thus "\<exists> stp>0. steps (st + length tp1 div 2, l, r) (tp1 @ tshift tp (length tp1 div 2) @ tp2) stp
- = (st' + length tp1 div 2, l', r')"
- apply(erule_tac exE)
- apply(rule_tac x = stp in exI, simp)
- apply(subgoal_tac "length (tp1 @ tshift tp (length tp1 div 2) @ tp2) mod 2 = 0")
- apply(simp only: steps_eq)
- using h
- apply(auto simp: t_ncorrect.simps shift_length)
- apply arith
- done
-qed
-
-
lemma t_twice_len_ge: "Suc 0 \<le> length t_twice div 2"
-apply(simp add: t_twice_def tMp.simps shift_length)
+apply(simp add: t_twice_def mopup.simps t_twice_compile_def)
done
lemma [intro]: "rec_calc_rel (recf.id (Suc 0) 0) [rs] rs"
@@ -1251,15 +1200,19 @@
using prime_rel_exec_eq[of "rec_mult" "[rs, 2]" "2*rs"]
apply(subgoal_tac "primerec rec_mult (Suc (Suc 0))", auto)
done
-lemma t_twice_correct: "\<exists>stp ln rn. steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>)
- (tm_of abc_twice @ tMp (Suc 0) (start_of twice_ly (length abc_twice) - Suc 0)) stp =
- (0, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (2 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+
+declare start_of.simps[simp del]
+
+lemma t_twice_correct:
+ "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ (tm_of abc_twice @ shift (mopup (Suc 0)) ((length (tm_of abc_twice) div 2))) stp =
+ (0, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
proof(case_tac "rec_ci rec_twice")
fix a b c
assume h: "rec_ci rec_twice = (a, b, c)"
- have "\<exists>stp m l. steps (Suc 0, Bk # Bk # ires, <[rs]> @ Bk\<^bsup>n\<^esup>) (tm_of abc_twice @ tMp (Suc 0)
- (start_of twice_ly (length abc_twice) - 1)) stp = (0, Bk\<^bsup>m\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (2*rs)\<^esup> @ Bk\<^bsup>l\<^esup>)"
- proof(rule_tac t_compiled_by_rec)
+ have "\<exists>stp m l. steps0 (Suc 0, Bk # Bk # ires, <[rs]> @ Bk\<up>(n)) (tm_of abc_twice @ shift (mopup 1)
+ (length (tm_of abc_twice) div 2)) stp = (0, Bk\<up>(m) @ Bk # Bk # ires, Oc\<up>(Suc (2*rs)) @ Bk\<up>(l))"
+ proof(rule_tac recursive_compile_to_tm_correct)
show "rec_ci rec_twice = (a, b, c)" by (simp add: h)
next
show "rec_calc_rel rec_twice [rs] (2 * rs)"
@@ -1268,187 +1221,221 @@
apply(rule_tac allI, case_tac k, auto)
done
next
- show "length [rs] = Suc 0" by simp
- next
- show "layout_of (a [+] dummy_abc (Suc 0)) = layout_of (a [+] dummy_abc (Suc 0))"
- by simp
+ show "length [rs] = 1" by simp
+ next
+ show "layout_of (a [+] dummy_abc 1) = layout_of (a [+] dummy_abc 1)" by simp
next
- show "start_of twice_ly (length abc_twice) =
- start_of (layout_of (a [+] dummy_abc (Suc 0))) (length (a [+] dummy_abc (Suc 0)))"
- using h
- apply(simp add: twice_ly_def abc_twice_def)
- done
- next
- show "tm_of abc_twice = tm_of (a [+] dummy_abc (Suc 0))"
+ show "tm_of abc_twice = tm_of (a [+] dummy_abc 1)"
using h
apply(simp add: abc_twice_def)
done
qed
- thus "\<exists>stp ln rn. steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>)
- (tm_of abc_twice @ tMp (Suc 0) (start_of twice_ly (length abc_twice) - Suc 0)) stp =
- (0, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (2 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ thus "?thesis"
apply(simp add: tape_of_nl_abv tape_of_nat_list.simps)
done
qed
-lemma change_termi_state_fetch: "\<lbrakk>fetch ap a b = (aa, st); st > 0\<rbrakk>
- \<Longrightarrow> fetch (change_termi_state ap) a b = (aa, st)"
-apply(case_tac b, auto simp: fetch.simps nth_of.simps change_termi_state.simps nth_map
- split: if_splits block.splits)
-done
-
-lemma change_termi_state_exec_in_range:
- "\<lbrakk>steps (st, l, r) ap stp = (st', l', r'); st' \<noteq> 0\<rbrakk>
- \<Longrightarrow> steps (st, l, r) (change_termi_state ap) stp = (st', l', r')"
-proof(induct stp arbitrary: st l r st' l' r', simp add: steps.simps)
- fix stp st l r st' l' r'
- assume ind: "\<And>st l r st' l' r'.
- \<lbrakk>steps (st, l, r) ap stp = (st', l', r'); st' \<noteq> 0\<rbrakk> \<Longrightarrow>
- steps (st, l, r) (change_termi_state ap) stp = (st', l', r')"
- and h: "steps (st, l, r) ap (Suc stp) = (st', l', r')" "st' \<noteq> 0"
- from h show "steps (st, l, r) (change_termi_state ap) (Suc stp) = (st', l', r')"
- proof(simp add: tstep_red, case_tac "steps (st, l, r) ap stp", simp)
- fix a b c
- assume g: "steps (st, l, r) ap stp = (a, b, c)"
- "tstep (a, b, c) ap = (st', l', r')" "0 < st'"
- hence "steps (st, l, r) (change_termi_state ap) stp = (a, b, c)"
- apply(rule_tac ind, simp)
- apply(case_tac a, simp_all add: tstep_0)
- done
- from g and this show "tstep (steps (st, l, r) (change_termi_state ap) stp)
- (change_termi_state ap) = (st', l', r')"
- apply(simp add: tstep.simps)
- apply(case_tac "fetch ap a (case c of [] \<Rightarrow> Bk | x # xs \<Rightarrow> x)", simp)
- apply(subgoal_tac "fetch (change_termi_state ap) a (case c of [] \<Rightarrow> Bk | x # xs \<Rightarrow> x)
- = (aa, st')", simp)
- apply(simp add: change_termi_state_fetch)
- done
- qed
+
+lemma adjust_fetch0:
+ "\<lbrakk>0 < a; a \<le> length ap div 2; fetch ap a b = (aa, 0)\<rbrakk>
+ \<Longrightarrow> fetch (adjust ap) a b = (aa, Suc (length ap div 2))"
+apply(case_tac b, auto simp: fetch.simps nth_of.simps nth_map
+ split: if_splits)
+apply(case_tac [!] a, auto simp: fetch.simps nth_of.simps)
+done
+
+lemma adjust_fetch_norm:
+ "\<lbrakk>st > 0; st \<le> length tp div 2; fetch ap st b = (aa, ns); ns \<noteq> 0\<rbrakk>
+ \<Longrightarrow> fetch (turing_basic.adjust ap) st b = (aa, ns)"
+ apply(case_tac b, auto simp: fetch.simps nth_of.simps nth_map
+ split: if_splits)
+apply(case_tac [!] st, auto simp: fetch.simps nth_of.simps)
+done
+
+lemma adjust_step_eq:
+ assumes exec: "step0 (st,l,r) ap = (st', l', r')"
+ and wf_tm: "tm_wf (ap, 0)"
+ and notfinal: "st' > 0"
+ shows "step0 (st, l, r) (adjust ap) = (st', l', r')"
+ using assms
+proof -
+ have "st > 0"
+ using assms
+ by(case_tac st, simp_all add: step.simps fetch.simps)
+ moreover hence "st \<le> (length ap) div 2"
+ using assms
+ apply(case_tac "st \<le> (length ap) div 2", simp)
+ apply(case_tac st, auto simp: step.simps fetch.simps)
+ apply(case_tac "read r", simp_all add: fetch.simps nth_of.simps)
+ done
+ ultimately have "fetch (adjust ap) st (read r) = fetch ap st (read r)"
+ using assms
+ apply(case_tac "fetch ap st (read r)")
+ apply(drule_tac adjust_fetch_norm, simp_all)
+ apply(simp add: step.simps)
+ done
+ thus "?thesis"
+ using exec
+ by(simp add: step.simps)
qed
-lemma change_termi_state_fetch0:
- "\<lbrakk>0 < a; a \<le> length ap div 2; t_correct ap; fetch ap a b = (aa, 0)\<rbrakk>
- \<Longrightarrow> fetch (change_termi_state ap) a b = (aa, Suc (length ap div 2))"
-apply(case_tac b, auto simp: fetch.simps nth_of.simps change_termi_state.simps nth_map
- split: if_splits block.splits)
-done
-
-lemma turing_change_termi_state:
- "\<lbrakk>steps (Suc 0, l, r) ap stp = (0, l', r'); t_correct ap\<rbrakk>
- \<Longrightarrow> \<exists> stp. steps (Suc 0, l, r) (change_termi_state ap) stp =
+declare adjust.simps[simp del]
+
+lemma adjust_steps_eq:
+ assumes exec: "steps0 (st,l,r) ap stp = (st', l', r')"
+ and wf_tm: "tm_wf (ap, 0)"
+ and notfinal: "st' > 0"
+ shows "steps0 (st, l, r) (adjust ap) stp = (st', l', r')"
+ using exec notfinal
+proof(induct stp arbitrary: st' l' r')
+ case 0
+ thus "?case"
+ by(simp add: steps.simps)
+next
+ case (Suc stp st' l' r')
+ have ind: "\<And>st' l' r'. \<lbrakk>steps0 (st, l, r) ap stp = (st', l', r'); 0 < st'\<rbrakk>
+ \<Longrightarrow> steps0 (st, l, r) (turing_basic.adjust ap) stp = (st', l', r')" by fact
+ have h: "steps0 (st, l, r) ap (Suc stp) = (st', l', r')" by fact
+ have g: "0 < st'" by fact
+ obtain st'' l'' r'' where a: "steps0 (st, l, r) ap stp = (st'', l'', r'')"
+ by (metis prod_cases3)
+ hence c:"0 < st''"
+ using h g
+ apply(simp add: step_red)
+ apply(case_tac st'', auto)
+ done
+ hence b: "steps0 (st, l, r) (turing_basic.adjust ap) stp = (st'', l'', r'')"
+ using a
+ by(rule_tac ind, simp_all)
+ thus "?case"
+ using assms a b h g
+ apply(simp add: step_red)
+ apply(rule_tac adjust_step_eq, simp_all)
+ done
+qed
+
+lemma adjust_halt_eq:
+ assumes exec: "steps0 (1, l, r) ap stp = (0, l', r')"
+ and tm_wf: "tm_wf (ap, 0)"
+ shows "\<exists> stp. steps0 (Suc 0, l, r) (adjust ap) stp =
(Suc (length ap div 2), l', r')"
-apply(drule first_halt_point)
-apply(erule_tac exE)
-apply(rule_tac x = "Suc stp" in exI, simp add: tstep_red)
-apply(case_tac "steps (Suc 0, l, r) ap stp")
-apply(simp add: isS0_def change_termi_state_exec_in_range)
-apply(subgoal_tac "steps (Suc 0, l, r) (change_termi_state ap) stp = (a, b, c)", simp)
-apply(simp add: tstep.simps)
-apply(case_tac "fetch ap a (case c of [] \<Rightarrow> Bk | x # xs \<Rightarrow> x)", simp)
-apply(subgoal_tac "fetch (change_termi_state ap) a
- (case c of [] \<Rightarrow> Bk | x # xs \<Rightarrow> x) = (aa, Suc (length ap div 2))", simp)
-apply(rule_tac ap = ap in change_termi_state_fetch0, simp_all)
-apply(rule_tac tp = "(l, r)" and l = b and r = c and stp = stp and A = ap in s_keep, simp_all)
-apply(simp add: change_termi_state_exec_in_range)
+proof -
+ have "\<exists> stp. \<not> is_final (steps0 (1, l, r) ap stp) \<and> (steps0 (1, l, r) ap (Suc stp) = (0, l', r'))"
+ thm before_final using exec
+ by(erule_tac before_final)
+ then obtain stpa where a:
+ "\<not> is_final (steps0 (1, l, r) ap stpa) \<and> (steps0 (1, l, r) ap (Suc stpa) = (0, l', r'))" ..
+ obtain sa la ra where b:"steps0 (1, l, r) ap stpa = (sa, la, ra)" by (metis prod_cases3)
+ hence c: "steps0 (Suc 0, l, r) (adjust ap) stpa = (sa, la, ra)"
+ using assms a
+ apply(rule_tac adjust_steps_eq, simp_all)
+ done
+ have d: "sa \<le> length ap div 2"
+ using steps_in_range[of "(l, r)" ap stpa] a tm_wf b
+ by(simp)
+ obtain ac ns where e: "fetch ap sa (read ra) = (ac, ns)"
+ by (metis prod.exhaust)
+ hence f: "ns = 0"
+ using b a
+ apply(simp add: step_red step.simps)
+ done
+ have k: "fetch (adjust ap) sa (read ra) = (ac, Suc (length ap div 2))"
+ using a b c d e f
+ apply(rule_tac adjust_fetch0, simp_all)
+ done
+ from a b e f k and c show "?thesis"
+ apply(rule_tac x = "Suc stpa" in exI)
+ apply(simp add: step_red, auto)
+ apply(simp add: step.simps)
+ done
+qed
+
+declare tm_wf.simps[simp del]
+
+lemma [simp]: " tm_wf (t_twice_compile, 0)"
+apply(simp only: t_twice_compile_def)
+apply(rule_tac t_compiled_correct)
+apply(simp_all add: abc_twice_def)
done
lemma t_twice_change_term_state:
- "\<exists> stp ln rn. steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_twice stp
- = (Suc t_twice_len, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (2 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
-using t_twice_correct[of ires rs n]
-apply(erule_tac exE)
-apply(erule_tac exE)
-apply(erule_tac exE)
-proof(drule_tac turing_change_termi_state)
- fix stp ln rn
- show "t_correct (tm_of abc_twice @ tMp (Suc 0) (start_of twice_ly (length abc_twice) - Suc 0))"
- apply(rule_tac t_compiled_correct, simp_all)
- apply(simp add: twice_ly_def)
+ "\<exists> stp ln rn. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) t_twice stp
+ = (Suc t_twice_len, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
+proof -
+ have "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ (tm_of abc_twice @ shift (mopup (Suc 0)) ((length (tm_of abc_twice) div 2))) stp =
+ (0, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
+ by(rule_tac t_twice_correct)
+ then obtain stp ln rn where " steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ (tm_of abc_twice @ shift (mopup (Suc 0)) ((length (tm_of abc_twice) div 2))) stp =
+ (0, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))" by blast
+ hence "\<exists> stp. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ (adjust t_twice_compile) stp
+ = (Suc (length t_twice_compile div 2), Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
+ thm adjust_halt_eq
+ apply(rule_tac stp = stp in adjust_halt_eq)
+ apply(simp add: t_twice_compile_def, auto)
done
-next
- fix stp ln rn
- show "\<exists>stp. steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>)
- (change_termi_state (tm_of abc_twice @ tMp (Suc 0)
- (start_of twice_ly (length abc_twice) - Suc 0))) stp =
- (Suc (length (tm_of abc_twice @ tMp (Suc 0) (start_of twice_ly (length abc_twice) - Suc 0)) div 2),
- Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (2 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>) \<Longrightarrow>
- \<exists>stp ln rn. steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_twice stp =
- (Suc t_twice_len, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (2 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- apply(erule_tac exE)
- apply(simp add: t_twice_len_def t_twice_def)
- apply(rule_tac x = stp in exI, rule_tac x = ln in exI, rule_tac x = rn in exI, simp)
- done
+ then obtain stpb where
+ "steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ (adjust t_twice_compile) stpb
+ = (Suc (length t_twice_compile div 2), Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))" ..
+ thus "?thesis"
+ apply(simp add: t_twice_def t_twice_len_def)
+ by metis
qed
+lemma [intro]: "length t_wcode_main_first_part mod 2 = 0"
+apply(auto simp: t_wcode_main_first_part_def)
+done
+
lemma t_twice_append_pre:
- "steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_twice stp
- = (Suc t_twice_len, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (2 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)
- \<Longrightarrow> \<exists> stp>0. steps (Suc 0 + length t_wcode_main_first_part div 2, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>)
- (t_wcode_main_first_part @ tshift t_twice (length t_wcode_main_first_part div 2) @
- ([(L, 1), (L, 1)] @ tshift t_fourtimes (t_twice_len + 13) @ [(L, 1), (L, 1)])) stp
- = (Suc (t_twice_len) + length t_wcode_main_first_part div 2, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (2 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
-proof(rule_tac t_tshift_lemma, simp_all add: t_twice_len_ge)
- assume "steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_twice stp =
- (Suc t_twice_len, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (2 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- thus "0 < stp"
- apply(case_tac stp, simp add: steps.simps t_twice_len_ge t_twice_len_def)
- using t_twice_len_ge
- apply(simp, simp)
- done
-next
- show "t_ncorrect t_wcode_main_first_part"
- apply(simp add: t_ncorrect.simps t_wcode_main_first_part_def)
- done
-next
- show "t_ncorrect t_twice"
- using length_tm_even[of abc_twice]
- apply(auto simp: t_ncorrect.simps t_twice_def)
- apply(arith)
- done
-next
- show "t_ncorrect ((L, Suc 0) # (L, Suc 0) #
- tshift t_fourtimes (t_twice_len + 13) @ [(L, Suc 0), (L, Suc 0)])"
- using length_tm_even[of abc_fourtimes]
- apply(simp add: t_ncorrect.simps shift_length t_fourtimes_def)
- apply arith
- done
-qed
-
+ "steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) t_twice stp
+ = (Suc t_twice_len, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))
+ \<Longrightarrow> steps0 (Suc 0 + length t_wcode_main_first_part div 2, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ (t_wcode_main_first_part @ shift t_twice (length t_wcode_main_first_part div 2) @
+ ([(L, 1), (L, 1)] @ shift t_fourtimes (t_twice_len + 13) @ [(L, 1), (L, 1)])) stp
+ = (Suc (t_twice_len) + length t_wcode_main_first_part div 2,
+ Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
+by(rule_tac tm_append_shift_append_steps, auto)
+
lemma t_twice_append:
- "\<exists> stp ln rn. steps (Suc 0 + length t_wcode_main_first_part div 2, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>)
- (t_wcode_main_first_part @ tshift t_twice (length t_wcode_main_first_part div 2) @
- ([(L, 1), (L, 1)] @ tshift t_fourtimes (t_twice_len + 13) @ [(L, 1), (L, 1)])) stp
- = (Suc (t_twice_len) + length t_wcode_main_first_part div 2, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (2 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ "\<exists> stp ln rn. steps0 (Suc 0 + length t_wcode_main_first_part div 2, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ (t_wcode_main_first_part @ shift t_twice (length t_wcode_main_first_part div 2) @
+ ([(L, 1), (L, 1)] @ shift t_fourtimes (t_twice_len + 13) @ [(L, 1), (L, 1)])) stp
+ = (Suc (t_twice_len) + length t_wcode_main_first_part div 2, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
using t_twice_change_term_state[of ires rs n]
apply(erule_tac exE)
apply(erule_tac exE)
apply(erule_tac exE)
apply(drule_tac t_twice_append_pre)
- apply(erule_tac exE)
- apply(rule_tac x = stpa in exI, rule_tac x = ln in exI, rule_tac x = rn in exI)
+ apply(rule_tac x = stp in exI, rule_tac x = ln in exI, rule_tac x = rn in exI)
apply(simp)
done
+lemma mopup_mod2: "length (mopup k) mod 2 = 0"
+apply(auto simp: mopup.simps)
+by arith
+
lemma [simp]: "fetch t_wcode_main (Suc (t_twice_len + length t_wcode_main_first_part div 2)) Oc
= (L, Suc 0)"
apply(subgoal_tac "length (t_twice) mod 2 = 0")
apply(simp add: t_wcode_main_def nth_append fetch.simps t_wcode_main_first_part_def
- nth_of.simps shift_length t_twice_len_def, auto)
-apply(simp add: t_twice_def)
-apply(subgoal_tac "length (tm_of abc_twice) mod 2 = 0")
-apply arith
-apply(rule_tac tm_even)
-done
+ nth_of.simps t_twice_len_def, auto)
+apply(simp add: t_twice_def t_twice_compile_def)
+using mopup_mod2[of 1]
+apply(simp)
+by arith
lemma wcode_jump1:
- "\<exists> stp ln rn. steps (Suc (t_twice_len) + length t_wcode_main_first_part div 2,
- Bk\<^bsup>m\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (2 * rs)\<^esup> @ Bk\<^bsup>n\<^esup>)
+ "\<exists> stp ln rn. steps0 (Suc (t_twice_len) + length t_wcode_main_first_part div 2,
+ Bk\<up>(m) @ Bk # Bk # ires, Oc\<up>(Suc (2 * rs)) @ Bk\<up>(n))
t_wcode_main stp
- = (Suc 0, Bk\<^bsup>ln\<^esup> @ Bk # ires, Bk # Oc\<^bsup>Suc (2 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ = (Suc 0, Bk\<up>(ln) @ Bk # ires, Bk # Oc\<up>(Suc (2 * rs)) @ Bk\<up>(rn))"
apply(rule_tac x = "Suc 0" in exI, rule_tac x = "m" in exI, rule_tac x = n in exI)
-apply(simp add: steps.simps tstep.simps exp_ind_def new_tape.simps)
-apply(case_tac m, simp, simp add: exp_ind_def)
-apply(simp add: exp_ind_def[THEN sym] exp_ind[THEN sym])
+apply(simp add: steps.simps step.simps exp_ind)
+apply(case_tac m, simp_all)
+apply(simp add: exp_ind[THEN sym])
done
lemma wcode_main_first_part_len:
@@ -1457,27 +1444,27 @@
done
lemma wcode_double_case:
- shows "\<exists>stp ln rn. steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Oc # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (Suc 0, Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires, Bk # Oc\<^bsup>Suc (2 * rs + 2)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ shows "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (Suc 0, Bk # Bk\<up>(ln) @ Oc # ires, Bk # Oc\<up>(Suc (2 * rs + 2)) @ Bk\<up>(rn))"
proof -
- have "\<exists>stp ln rn. steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Oc # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (13, Bk # Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires, Oc\<^bsup>Suc (Suc rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ have "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (13, Bk # Bk # Bk\<up>(ln) @ Oc # ires, Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
using wcode_double_case_first_correctness[of ires rs m n]
apply(simp)
apply(erule_tac exE)
- apply(case_tac "steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Oc # ires,
- Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main na",
+ apply(case_tac "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires,
+ Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main na",
auto simp: wcode_double_case_inv.simps
wcode_before_double.simps)
apply(rule_tac x = na in exI, rule_tac x = ln in exI, rule_tac x = rn in exI)
apply(simp)
done
from this obtain stpa lna rna where stp1:
- "steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Oc # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stpa =
- (13, Bk # Bk # Bk\<^bsup>lna\<^esup> @ Oc # ires, Oc\<^bsup>Suc (Suc rs)\<^esup> @ Bk\<^bsup>rna\<^esup>)" by blast
- have "\<exists> stp ln rn. steps (13, Bk # Bk # Bk\<^bsup>lna\<^esup> @ Oc # ires, Oc\<^bsup>Suc (Suc rs)\<^esup> @ Bk\<^bsup>rna\<^esup>) t_wcode_main stp =
- (13 + t_twice_len, Bk # Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires, Oc\<^bsup>Suc (Suc (Suc (2 *rs)))\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- using t_twice_append[of "Bk\<^bsup>lna\<^esup> @ Oc # ires" "Suc rs" rna]
+ "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stpa =
+ (13, Bk # Bk # Bk\<up>(lna) @ Oc # ires, Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rna))" by blast
+ have "\<exists> stp ln rn. steps0 (13, Bk # Bk # Bk\<up>(lna) @ Oc # ires, Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rna)) t_wcode_main stp =
+ (13 + t_twice_len, Bk # Bk # Bk\<up>(ln) @ Oc # ires, Oc\<up>(Suc (Suc (Suc (2 *rs)))) @ Bk\<up>(rn))"
+ using t_twice_append[of "Bk\<up>(lna) @ Oc # ires" "Suc rs" rna]
apply(erule_tac exE)
apply(erule_tac exE)
apply(erule_tac exE)
@@ -1485,14 +1472,14 @@
apply(rule_tac x = stp in exI, rule_tac x = "ln + lna" in exI,
rule_tac x = rn in exI)
apply(simp add: t_wcode_main_def)
- apply(simp add: exp_ind_def[THEN sym] exp_add[THEN sym])
+ apply(simp add: replicate_Suc[THEN sym] exp_add[THEN sym] del: replicate_Suc)
done
from this obtain stpb lnb rnb where stp2:
- "steps (13, Bk # Bk # Bk\<^bsup>lna\<^esup> @ Oc # ires, Oc\<^bsup>Suc (Suc rs)\<^esup> @ Bk\<^bsup>rna\<^esup>) t_wcode_main stpb =
- (13 + t_twice_len, Bk # Bk # Bk\<^bsup>lnb\<^esup> @ Oc # ires, Oc\<^bsup>Suc (Suc (Suc (2 *rs)))\<^esup> @ Bk\<^bsup>rnb\<^esup>)" by blast
- have "\<exists>stp ln rn. steps (13 + t_twice_len, Bk # Bk # Bk\<^bsup>lnb\<^esup> @ Oc # ires,
- Oc\<^bsup>Suc (Suc (Suc (2 *rs)))\<^esup> @ Bk\<^bsup>rnb\<^esup>) t_wcode_main stp =
- (Suc 0, Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires, Bk # Oc\<^bsup>Suc (Suc (Suc (2 *rs)))\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ "steps0 (13, Bk # Bk # Bk\<up>(lna) @ Oc # ires, Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rna)) t_wcode_main stpb =
+ (13 + t_twice_len, Bk # Bk # Bk\<up>(lnb) @ Oc # ires, Oc\<up>(Suc (Suc (Suc (2 *rs)))) @ Bk\<up>(rnb))" by blast
+ have "\<exists>stp ln rn. steps0 (13 + t_twice_len, Bk # Bk # Bk\<up>(lnb) @ Oc # ires,
+ Oc\<up>(Suc (Suc (Suc (2 *rs)))) @ Bk\<up>(rnb)) t_wcode_main stp =
+ (Suc 0, Bk # Bk\<up>(ln) @ Oc # ires, Bk # Oc\<up>(Suc (Suc (Suc (2 *rs)))) @ Bk\<up>(rn))"
using wcode_jump1[of lnb "Oc # ires" "Suc rs" rnb]
apply(erule_tac exE)
apply(erule_tac exE)
@@ -1500,15 +1487,15 @@
apply(rule_tac x = stp in exI,
rule_tac x = ln in exI,
rule_tac x = rn in exI, simp add:wcode_main_first_part_len t_wcode_main_def)
- apply(subgoal_tac "Bk\<^bsup>lnb\<^esup> @ Bk # Bk # Oc # ires = Bk # Bk # Bk\<^bsup>lnb\<^esup> @ Oc # ires", simp)
- apply(simp add: exp_ind_def[THEN sym] exp_ind[THEN sym])
+ apply(subgoal_tac "Bk\<up>(lnb) @ Bk # Bk # Oc # ires = Bk # Bk # Bk\<up>(lnb) @ Oc # ires", simp)
+ apply(simp add: replicate_Suc[THEN sym] exp_ind[THEN sym] del: replicate_Suc)
apply(simp)
- apply(case_tac lnb, simp, simp add: exp_ind_def[THEN sym] exp_ind)
+ apply(simp add: replicate_Suc[THEN sym] exp_ind del: replicate_Suc)
done
from this obtain stpc lnc rnc where stp3:
- "steps (13 + t_twice_len, Bk # Bk # Bk\<^bsup>lnb\<^esup> @ Oc # ires,
- Oc\<^bsup>Suc (Suc (Suc (2 *rs)))\<^esup> @ Bk\<^bsup>rnb\<^esup>) t_wcode_main stpc =
- (Suc 0, Bk # Bk\<^bsup>lnc\<^esup> @ Oc # ires, Bk # Oc\<^bsup>Suc (Suc (Suc (2 *rs)))\<^esup> @ Bk\<^bsup>rnc\<^esup>)"
+ "steps0 (13 + t_twice_len, Bk # Bk # Bk\<up>(lnb) @ Oc # ires,
+ Oc\<up>(Suc (Suc (Suc (2 *rs)))) @ Bk\<up>(rnb)) t_wcode_main stpc =
+ (Suc 0, Bk # Bk\<up>(lnc) @ Oc # ires, Bk # Oc\<up>(Suc (Suc (Suc (2 *rs)))) @ Bk\<up>(rnc))"
by blast
from stp1 stp2 stp3 show "?thesis"
apply(rule_tac x = "stpa + stpb + stpc" in exI, rule_tac x = lnc in exI,
@@ -1522,15 +1509,15 @@
fun wcode_on_left_moving_2_B :: "bin_inv_t"
where
"wcode_on_left_moving_2_B ires rs (l, r) =
- (\<exists> ml mr rn. l = Bk\<^bsup>ml\<^esup> @ Oc # Bk # Oc # ires \<and>
- r = Bk\<^bsup>mr\<^esup> @ Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ (\<exists> ml mr rn. l = Bk\<up>(ml) @ Oc # Bk # Oc # ires \<and>
+ r = Bk\<up>(mr) @ Oc\<up>(Suc rs) @ Bk\<up>(rn) \<and>
ml + mr > Suc 0 \<and> mr > 0)"
fun wcode_on_left_moving_2_O :: "bin_inv_t"
where
"wcode_on_left_moving_2_O ires rs (l, r) =
(\<exists> ln rn. l = Bk # Oc # ires \<and>
- r = Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ r = Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
fun wcode_on_left_moving_2 :: "bin_inv_t"
where
@@ -1542,49 +1529,49 @@
where
"wcode_on_checking_2 ires rs (l, r) =
(\<exists> ln rn. l = Oc#ires \<and>
- r = Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ r = Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
fun wcode_goon_checking :: "bin_inv_t"
where
"wcode_goon_checking ires rs (l, r) =
(\<exists> ln rn. l = ires \<and>
- r = Oc # Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ r = Oc # Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
fun wcode_right_move :: "bin_inv_t"
where
"wcode_right_move ires rs (l, r) =
(\<exists> ln rn. l = Oc # ires \<and>
- r = Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ r = Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
fun wcode_erase2 :: "bin_inv_t"
where
"wcode_erase2 ires rs (l, r) =
(\<exists> ln rn. l = Bk # Oc # ires \<and>
- tl r = Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ tl r = Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
fun wcode_on_right_moving_2 :: "bin_inv_t"
where
"wcode_on_right_moving_2 ires rs (l, r) =
- (\<exists> ml mr rn. l = Bk\<^bsup>ml\<^esup> @ Oc # ires \<and>
- r = Bk\<^bsup>mr\<^esup> @ Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup> \<and> ml + mr > Suc 0)"
+ (\<exists> ml mr rn. l = Bk\<up>(ml) @ Oc # ires \<and>
+ r = Bk\<up>(mr) @ Oc\<up>(Suc rs) @ Bk\<up>(rn) \<and> ml + mr > Suc 0)"
fun wcode_goon_right_moving_2 :: "bin_inv_t"
where
"wcode_goon_right_moving_2 ires rs (l, r) =
- (\<exists> ml mr ln rn. l = Oc\<^bsup>ml\<^esup> @ Bk # Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires \<and>
- r = Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<and> ml + mr = Suc rs)"
+ (\<exists> ml mr ln rn. l = Oc\<up>(ml) @ Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and>
+ r = Oc\<up>(mr) @ Bk\<up>(rn) \<and> ml + mr = Suc rs)"
fun wcode_backto_standard_pos_2_B :: "bin_inv_t"
where
"wcode_backto_standard_pos_2_B ires rs (l, r) =
- (\<exists> ln rn. l = Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires \<and>
- r = Bk # Oc\<^bsup>Suc (Suc rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ (\<exists> ln rn. l = Bk # Bk\<up>(ln) @ Oc # ires \<and>
+ r = Bk # Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
fun wcode_backto_standard_pos_2_O :: "bin_inv_t"
where
"wcode_backto_standard_pos_2_O ires rs (l, r) =
- (\<exists> ml mr ln rn. l = Oc\<^bsup>ml \<^esup>@ Bk # Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires \<and>
- r = Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ (\<exists> ml mr ln rn. l = Oc\<up>(ml )@ Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and>
+ r = Oc\<up>(mr) @ Bk\<up>(rn) \<and>
ml + mr = (Suc (Suc rs)) \<and> mr > 0)"
fun wcode_backto_standard_pos_2 :: "bin_inv_t"
@@ -1596,8 +1583,8 @@
fun wcode_before_fourtimes :: "bin_inv_t"
where
"wcode_before_fourtimes ires rs (l, r) =
- (\<exists> ln rn. l = Bk # Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires \<and>
- r = Oc\<^bsup>Suc (Suc rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ (\<exists> ln rn. l = Bk # Bk # Bk\<up>(ln) @ Oc # ires \<and>
+ r = Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
declare wcode_on_left_moving_2_B.simps[simp del] wcode_on_left_moving_2.simps[simp del]
wcode_on_left_moving_2_O.simps[simp del] wcode_on_checking_2.simps[simp del]
@@ -1632,11 +1619,11 @@
declare wcode_fourtimes_case_inv.simps[simp del]
-fun wcode_fourtimes_case_state :: "t_conf \<Rightarrow> nat"
+fun wcode_fourtimes_case_state :: "config \<Rightarrow> nat"
where
"wcode_fourtimes_case_state (st, l, r) = 13 - st"
-fun wcode_fourtimes_case_step :: "t_conf \<Rightarrow> nat"
+fun wcode_fourtimes_case_step :: "config \<Rightarrow> nat"
where
"wcode_fourtimes_case_step (st, l, r) =
(if st = Suc 0 then length l
@@ -1648,13 +1635,13 @@
else if st = 12 then length l
else 0)"
-fun wcode_fourtimes_case_measure :: "t_conf \<Rightarrow> nat \<times> nat"
+fun wcode_fourtimes_case_measure :: "config \<Rightarrow> nat \<times> nat"
where
"wcode_fourtimes_case_measure (st, l, r) =
(wcode_fourtimes_case_state (st, l, r),
wcode_fourtimes_case_step (st, l, r))"
-definition wcode_fourtimes_case_le :: "(t_conf \<times> t_conf) set"
+definition wcode_fourtimes_case_le :: "(config \<times> config) set"
where "wcode_fourtimes_case_le \<equiv> (inv_image lex_pair wcode_fourtimes_case_measure)"
lemma wf_wcode_fourtimes_case_le[intro]: "wf wcode_fourtimes_case_le"
@@ -1666,55 +1653,75 @@
done
lemma [simp]: "fetch t_wcode_main 7 Oc = (R, 8)"
-apply(simp add: t_wcode_main_def fetch.simps
+apply(subgoal_tac "7 = Suc 6")
+apply(simp only: t_wcode_main_def fetch.simps
t_wcode_main_first_part_def nth_of.simps)
+apply(auto)
done
lemma [simp]: "fetch t_wcode_main 8 Bk = (R, 9)"
-apply(simp add: t_wcode_main_def fetch.simps
+apply(subgoal_tac "8 = Suc 7")
+apply(simp only: t_wcode_main_def fetch.simps
t_wcode_main_first_part_def nth_of.simps)
-done
+apply(auto)
+done
+
lemma [simp]: "fetch t_wcode_main 9 Bk = (R, 10)"
-apply(simp add: t_wcode_main_def fetch.simps
+apply(subgoal_tac "9 = Suc 8")
+apply(simp only: t_wcode_main_def fetch.simps
t_wcode_main_first_part_def nth_of.simps)
+apply(auto)
done
lemma [simp]: "fetch t_wcode_main 9 Oc = (W0, 9)"
-apply(simp add: t_wcode_main_def fetch.simps
+apply(subgoal_tac "9 = Suc 8")
+apply(simp only: t_wcode_main_def fetch.simps
t_wcode_main_first_part_def nth_of.simps)
+apply(auto)
done
lemma [simp]: "fetch t_wcode_main 10 Bk = (R, 10)"
-apply(simp add: t_wcode_main_def fetch.simps
+apply(subgoal_tac "10 = Suc 9")
+apply(simp only: t_wcode_main_def fetch.simps
t_wcode_main_first_part_def nth_of.simps)
+apply(auto)
done
lemma [simp]: "fetch t_wcode_main 10 Oc = (R, 11)"
-apply(simp add: t_wcode_main_def fetch.simps
+apply(subgoal_tac "10 = Suc 9")
+apply(simp only: t_wcode_main_def fetch.simps
t_wcode_main_first_part_def nth_of.simps)
-done
+apply(auto)
+done
lemma [simp]: "fetch t_wcode_main 11 Bk = (W1, 12)"
-apply(simp add: t_wcode_main_def fetch.simps
+apply(subgoal_tac "11 = Suc 10")
+apply(simp only: t_wcode_main_def fetch.simps
t_wcode_main_first_part_def nth_of.simps)
+apply(auto)
done
lemma [simp]: "fetch t_wcode_main 11 Oc = (R, 11)"
-apply(simp add: t_wcode_main_def fetch.simps
+apply(subgoal_tac "11 = Suc 10")
+apply(simp only: t_wcode_main_def fetch.simps
t_wcode_main_first_part_def nth_of.simps)
-done
+apply(auto)
+done
lemma [simp]: "fetch t_wcode_main 12 Oc = (L, 12)"
-apply(simp add: t_wcode_main_def fetch.simps
+apply(subgoal_tac "12 = Suc 11")
+apply(simp only: t_wcode_main_def fetch.simps
t_wcode_main_first_part_def nth_of.simps)
-done
+apply(auto)
+done
lemma [simp]: "fetch t_wcode_main 12 Bk = (R, t_twice_len + 14)"
-apply(simp add: t_wcode_main_def fetch.simps
+apply(subgoal_tac "12 = Suc 11")
+apply(simp only: t_wcode_main_def fetch.simps
t_wcode_main_first_part_def nth_of.simps)
-done
-
+apply(auto)
+done
lemma [simp]: "wcode_on_left_moving_2 ires rs (b, []) = False"
apply(auto simp: wcode_fourtimes_invs)
@@ -1737,27 +1744,27 @@
done
lemma [simp]: "wcode_on_right_moving_2 ires rs (b, []) = False"
-apply(auto simp: wcode_fourtimes_invs exponent_def)
+apply(auto simp: wcode_fourtimes_invs)
done
lemma [simp]: "wcode_backto_standard_pos_2 ires rs (b, []) = False"
-apply(auto simp: wcode_fourtimes_invs exponent_def)
+apply(auto simp: wcode_fourtimes_invs)
done
lemma [simp]: "wcode_on_left_moving_2 ires rs (b, Bk # list) \<Longrightarrow> b \<noteq> []"
apply(simp add: wcode_fourtimes_invs, auto)
-done
-
+done
+
lemma [simp]: "wcode_on_left_moving_2 ires rs (b, Bk # list) \<Longrightarrow> wcode_on_left_moving_2 ires rs (tl b, hd b # Bk # list)"
apply(simp only: wcode_fourtimes_invs)
apply(erule_tac disjE)
apply(erule_tac exE)+
apply(case_tac ml, simp)
apply(rule_tac x = "mr - (Suc (Suc 0))" in exI, rule_tac x = rn in exI, simp)
-apply(case_tac mr, simp, case_tac nat, simp, simp add: exp_ind)
+apply(case_tac mr, simp, case_tac nat, simp, simp add: exp_ind del: replicate_Suc)
apply(rule_tac disjI1)
apply(rule_tac x = nat in exI, rule_tac x = "Suc mr" in exI, rule_tac x = rn in exI,
- simp add: exp_ind_def)
+ simp add: replicate_Suc)
apply(simp)
done
@@ -1791,7 +1798,7 @@
lemma [simp]: "wcode_erase2 ires rs (b, Bk # list) \<Longrightarrow> wcode_on_right_moving_2 ires rs (Bk # b, list)"
apply(auto simp:wcode_fourtimes_invs )
apply(rule_tac x = "Suc (Suc 0)" in exI, simp add: exp_ind)
-apply(rule_tac x = "Suc (Suc ln)" in exI, simp add: exp_ind, auto)
+apply(rule_tac x = "Suc (Suc ln)" in exI, simp add: exp_ind del: replicate_Suc)
done
lemma [simp]: "wcode_on_right_moving_2 ires rs (b, Bk # list) \<Longrightarrow> b \<noteq> []"
@@ -1801,8 +1808,8 @@
lemma [simp]: "wcode_on_right_moving_2 ires rs (b, Bk # list)
\<Longrightarrow> wcode_on_right_moving_2 ires rs (Bk # b, list)"
apply(auto simp: wcode_fourtimes_invs)
-apply(rule_tac x = "Suc ml" in exI, simp add: exp_ind_def)
-apply(rule_tac x = "mr - 1" in exI, case_tac mr, auto simp: exp_ind_def)
+apply(rule_tac x = "Suc ml" in exI, simp)
+apply(rule_tac x = "mr - 1" in exI, case_tac mr,auto)
done
lemma [simp]: "wcode_goon_right_moving_2 ires rs (b, Bk # list) \<Longrightarrow> b \<noteq> []"
@@ -1814,9 +1821,9 @@
apply(simp add: wcode_fourtimes_invs, auto)
apply(rule_tac x = ml in exI, auto)
apply(rule_tac x = "Suc 0" in exI, simp)
-apply(case_tac mr, simp_all add: exp_ind_def)
+apply(case_tac mr, simp_all)
apply(rule_tac x = "rn - 1" in exI, simp)
-apply(case_tac rn, simp, simp add: exp_ind_def)
+apply(case_tac rn, simp, simp)
done
lemma [simp]: "wcode_backto_standard_pos_2 ires rs (b, Bk # list) \<Longrightarrow> b \<noteq> []"
@@ -1830,7 +1837,7 @@
lemma [simp]: "wcode_on_left_moving_2 ires rs (b, Oc # list) \<Longrightarrow>
wcode_on_checking_2 ires rs (tl b, hd b # Oc # list)"
apply(auto simp: wcode_fourtimes_invs)
-apply(case_tac [!] mr, simp_all add: exp_ind_def)
+apply(case_tac [!] mr, simp_all)
done
lemma [simp]: "wcode_goon_right_moving_2 ires rs (b, []) \<Longrightarrow> b \<noteq> []"
@@ -1844,13 +1851,12 @@
apply(rule_tac disjI1)
apply(rule_tac x = ml in exI, rule_tac x = "Suc 0" in exI,
rule_tac x = ln in exI, rule_tac x = rn in exI, simp)
-apply(case_tac mr, simp, simp add: exp_ind_def)
done
lemma "wcode_backto_standard_pos_2 ires rs (b, Bk # list)
- \<Longrightarrow> (\<exists>ln. b = Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires) \<and> (\<exists>rn. list = Oc\<^bsup>Suc (Suc rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ \<Longrightarrow> (\<exists>ln. b = Bk # Bk\<up>(ln) @ Oc # ires) \<and> (\<exists>rn. list = Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
apply(auto simp: wcode_fourtimes_invs)
-apply(case_tac [!] mr, auto simp: exp_ind_def)
+apply(case_tac [!] mr, auto)
done
@@ -1887,10 +1893,10 @@
lemma [simp]: "wcode_on_right_moving_2 ires rs (b, Oc # list)
\<Longrightarrow> wcode_goon_right_moving_2 ires rs (Oc # b, list)"
apply(auto simp: wcode_fourtimes_invs)
-apply(case_tac mr, simp_all add: exp_ind_def)
+apply(case_tac mr, simp_all)
apply(rule_tac x = "Suc 0" in exI, auto)
apply(rule_tac x = "ml - 2" in exI)
-apply(case_tac ml, simp, case_tac nat, simp_all add: exp_ind_def)
+apply(case_tac ml, simp, case_tac nat, simp_all)
done
lemma [simp]: "wcode_goon_right_moving_2 ires rs (b, Oc # list) \<Longrightarrow> b \<noteq> []"
@@ -1898,9 +1904,9 @@
done
lemma [simp]: "wcode_backto_standard_pos_2 ires rs (b, Bk # list)
- \<Longrightarrow> (\<exists>ln. b = Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires) \<and> (\<exists>rn. list = Oc\<^bsup>Suc (Suc rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ \<Longrightarrow> (\<exists>ln. b = Bk # Bk\<up>(ln) @ Oc # ires) \<and> (\<exists>rn. list = Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
apply(simp add: wcode_fourtimes_invs, auto)
-apply(case_tac [!] mr, simp_all add: exp_ind_def)
+apply(case_tac [!] mr, simp_all)
done
lemma [simp]: "wcode_on_checking_2 ires rs (b, Oc # list) = False"
@@ -1910,9 +1916,9 @@
lemma [simp]: "wcode_goon_right_moving_2 ires rs (b, Oc # list) \<Longrightarrow>
wcode_goon_right_moving_2 ires rs (Oc # b, list)"
apply(simp only:wcode_fourtimes_invs, auto)
-apply(rule_tac x = "Suc ml" in exI, auto simp: exp_ind_def)
+apply(rule_tac x = "Suc ml" in exI, simp)
apply(rule_tac x = "mr - 1" in exI)
-apply(case_tac mr, case_tac rn, auto simp: exp_ind_def)
+apply(case_tac mr, case_tac rn, auto)
done
lemma [simp]: "wcode_backto_standard_pos_2 ires rs (b, Oc # list) \<Longrightarrow> b \<noteq> []"
@@ -1924,25 +1930,20 @@
apply(simp only: wcode_fourtimes_invs)
apply(erule_tac disjE)
apply(erule_tac exE)+
-apply(case_tac ml, simp)
-apply(rule_tac disjI2)
-apply(rule_tac conjI, rule_tac x = ln in exI, simp)
-apply(rule_tac x = rn in exI, simp)
-apply(rule_tac disjI1)
-apply(rule_tac x = nat in exI, rule_tac x = "Suc mr" in exI,
- rule_tac x = ln in exI, rule_tac x = rn in exI, simp add: exp_ind_def)
-apply(simp)
+apply(case_tac ml, auto)
+apply(rule_tac x = nat in exI, auto)
+apply(rule_tac x = "Suc mr" in exI, simp)
done
lemma wcode_fourtimes_case_first_correctness:
shows "let P = (\<lambda> (st, l, r). st = t_twice_len + 14) in
let Q = (\<lambda> (st, l, r). wcode_fourtimes_case_inv st ires rs (l, r)) in
- let f = (\<lambda> stp. steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # Oc # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp) in
+ let f = (\<lambda> stp. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp) in
\<exists> n .P (f n) \<and> Q (f (n::nat))"
proof -
let ?P = "(\<lambda> (st, l, r). st = t_twice_len + 14)"
let ?Q = "(\<lambda> (st, l, r). wcode_fourtimes_case_inv st ires rs (l, r))"
- let ?f = "(\<lambda> stp. steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # Oc # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp)"
+ let ?f = "(\<lambda> stp. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp)"
have "\<exists> n . ?P (?f n) \<and> ?Q (?f (n::nat))"
proof(rule_tac halt_lemma2)
show "wf wcode_fourtimes_case_le"
@@ -1951,19 +1952,21 @@
show "\<forall> na. \<not> ?P (?f na) \<and> ?Q (?f na) \<longrightarrow>
?Q (?f (Suc na)) \<and> (?f (Suc na), ?f na) \<in> wcode_fourtimes_case_le"
apply(rule_tac allI,
- case_tac "steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # Oc # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main na", simp,
+ case_tac "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main na", simp,
rule_tac impI)
- apply(simp add: tstep_red tstep.simps, case_tac c, simp, case_tac [2] aa, simp_all)
-
- apply(simp_all add: wcode_fourtimes_case_inv.simps new_tape.simps
+ apply(simp add: step_red step.simps, case_tac c, simp, case_tac [2] aa, simp_all)
+ apply(simp_all add: wcode_fourtimes_case_inv.simps
wcode_fourtimes_case_le_def lex_pair_def split: if_splits)
+ apply(auto simp: wcode_backto_standard_pos_2.simps wcode_backto_standard_pos_2_O.simps
+ wcode_backto_standard_pos_2_B.simps)
+ apply(case_tac mr, simp_all)
done
next
show "?Q (?f 0)"
apply(simp add: steps.simps wcode_fourtimes_case_inv.simps)
apply(simp add: wcode_on_left_moving_2.simps wcode_on_left_moving_2_B.simps
wcode_on_left_moving_2_O.simps)
- apply(rule_tac x = "Suc m" in exI, simp add: exp_ind_def)
+ apply(rule_tac x = "Suc m" in exI, simp )
apply(rule_tac x ="Suc 0" in exI, auto)
done
next
@@ -1981,196 +1984,199 @@
"t_fourtimes_len = (length t_fourtimes div 2)"
lemma t_fourtimes_len_gr: "t_fourtimes_len > 0"
-apply(simp add: t_fourtimes_len_def t_fourtimes_def)
+apply(simp add: t_fourtimes_len_def t_fourtimes_def mopup.simps t_fourtimes_compile_def)
+done
+
+lemma [intro]: "rec_calc_rel (constn 4) [rs] 4"
+using prime_rel_exec_eq[of "constn 4" "[rs]" 4]
+apply(subgoal_tac "primerec (constn 4) 1", auto)
+done
+
+lemma [intro]: "rec_calc_rel rec_mult [rs, 4] (4 * rs)"
+using prime_rel_exec_eq[of "rec_mult" "[rs, 4]" "4*rs"]
+apply(subgoal_tac "primerec rec_mult 2", auto simp: numeral_2_eq_2)
done
lemma t_fourtimes_correct:
- "\<exists>stp ln rn. steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>)
- (tm_of abc_fourtimes @ tMp (Suc 0) (start_of fourtimes_ly (length abc_fourtimes) - Suc 0)) stp =
- (0, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (4 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ (tm_of abc_fourtimes @ shift (mopup 1) (length (tm_of abc_fourtimes) div 2)) stp =
+ (0, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))"
proof(case_tac "rec_ci rec_fourtimes")
fix a b c
assume h: "rec_ci rec_fourtimes = (a, b, c)"
- have "\<exists>stp m l. steps (Suc 0, Bk # Bk # ires, <[rs]> @ Bk\<^bsup>n\<^esup>) (tm_of abc_fourtimes @ tMp (Suc 0)
- (start_of fourtimes_ly (length abc_fourtimes) - 1)) stp = (0, Bk\<^bsup>m\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (4*rs)\<^esup> @ Bk\<^bsup>l\<^esup>)"
- proof(rule_tac t_compiled_by_rec)
+ have "\<exists>stp m l. steps0 (Suc 0, Bk # Bk # ires, <[rs]> @ Bk\<up>(n)) (tm_of abc_fourtimes @ shift (mopup 1)
+ (length (tm_of abc_fourtimes) div 2)) stp = (0, Bk\<up>(m) @ Bk # Bk # ires, Oc\<up>(Suc (4*rs)) @ Bk\<up>(l))"
+ proof(rule_tac recursive_compile_to_tm_correct)
show "rec_ci rec_fourtimes = (a, b, c)" by (simp add: h)
next
show "rec_calc_rel rec_fourtimes [rs] (4 * rs)"
- using prime_rel_exec_eq [of rec_fourtimes "[rs]" "4 * rs"]
- apply(subgoal_tac "primerec rec_fourtimes (length [rs])")
- apply(simp_all add: rec_fourtimes_def rec_exec.simps)
- apply(auto)
- apply(simp only: Nat.One_nat_def[THEN sym], auto)
+ apply(simp add: rec_fourtimes_def)
+ apply(rule_tac rs = "[rs, 4]" in calc_cn, simp_all)
+ apply(rule_tac allI, case_tac k, auto simp: mult_lemma)
done
next
- show "length [rs] = Suc 0" by simp
- next
- show "layout_of (a [+] dummy_abc (Suc 0)) = layout_of (a [+] dummy_abc (Suc 0))"
- by simp
+ show "length [rs] = 1" by simp
+ next
+ show "layout_of (a [+] dummy_abc 1) = layout_of (a [+] dummy_abc 1)" by simp
next
- show "start_of fourtimes_ly (length abc_fourtimes) =
- start_of (layout_of (a [+] dummy_abc (Suc 0))) (length (a [+] dummy_abc (Suc 0)))"
- using h
- apply(simp add: fourtimes_ly_def abc_fourtimes_def)
- done
- next
- show "tm_of abc_fourtimes = tm_of (a [+] dummy_abc (Suc 0))"
+ show "tm_of abc_fourtimes = tm_of (a [+] dummy_abc 1)"
using h
apply(simp add: abc_fourtimes_def)
done
qed
- thus "\<exists>stp ln rn. steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>)
- (tm_of abc_fourtimes @ tMp (Suc 0) (start_of fourtimes_ly (length abc_fourtimes) - Suc 0)) stp =
- (0, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (4 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ thus "?thesis"
apply(simp add: tape_of_nl_abv tape_of_nat_list.simps)
done
qed
+lemma wf_fourtimes[intro]: "tm_wf (t_fourtimes_compile, 0)"
+apply(simp only: t_fourtimes_compile_def)
+apply(rule_tac t_compiled_correct)
+apply(simp_all add: abc_twice_def)
+done
+
lemma t_fourtimes_change_term_state:
- "\<exists> stp ln rn. steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_fourtimes stp
- = (Suc t_fourtimes_len, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (4 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
-using t_fourtimes_correct[of ires rs n]
-apply(erule_tac exE)
-apply(erule_tac exE)
-apply(erule_tac exE)
-proof(drule_tac turing_change_termi_state)
- fix stp ln rn
- show "t_correct (tm_of abc_fourtimes @ tMp (Suc 0)
- (start_of fourtimes_ly (length abc_fourtimes) - Suc 0))"
- apply(rule_tac t_compiled_correct, auto simp: fourtimes_ly_def)
+ "\<exists> stp ln rn. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) t_fourtimes stp
+ = (Suc t_fourtimes_len, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))"
+proof -
+ have "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ (tm_of abc_fourtimes @ shift (mopup 1) ((length (tm_of abc_fourtimes) div 2))) stp =
+ (0, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))"
+ by(rule_tac t_fourtimes_correct)
+ then obtain stp ln rn where
+ "steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ (tm_of abc_fourtimes @ shift (mopup 1) ((length (tm_of abc_fourtimes) div 2))) stp =
+ (0, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))" by blast
+ hence "\<exists> stp. steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ (adjust t_fourtimes_compile) stp
+ = (Suc (length t_fourtimes_compile div 2), Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))"
+ apply(rule_tac stp = stp in adjust_halt_eq)
+ apply(simp add: t_fourtimes_compile_def, auto)
done
-next
- fix stp ln rn
- show "\<exists>stp. steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>)
- (change_termi_state (tm_of abc_fourtimes @ tMp (Suc 0)
- (start_of fourtimes_ly (length abc_fourtimes) - Suc 0))) stp =
- (Suc (length (tm_of abc_fourtimes @ tMp (Suc 0) (start_of fourtimes_ly
- (length abc_fourtimes) - Suc 0)) div 2), Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (4 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>) \<Longrightarrow>
- \<exists>stp ln rn. steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_fourtimes stp =
- (Suc t_fourtimes_len, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (4 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- apply(erule_tac exE)
- apply(simp add: t_fourtimes_len_def t_fourtimes_def)
- apply(rule_tac x = stp in exI, rule_tac x = ln in exI, rule_tac x = rn in exI, simp)
- done
+ then obtain stpb where
+ "steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ (adjust t_fourtimes_compile) stpb
+ = (Suc (length t_fourtimes_compile div 2), Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))" ..
+ thus "?thesis"
+ apply(simp add: t_fourtimes_def t_fourtimes_len_def)
+ by metis
qed
+lemma [intro]: "length t_twice mod 2 = 0"
+apply(auto simp: t_twice_def t_twice_compile_def)
+done
+
lemma t_fourtimes_append_pre:
- "steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_fourtimes stp
- = (Suc t_fourtimes_len, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (4 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)
- \<Longrightarrow> \<exists> stp>0. steps (Suc 0 + length (t_wcode_main_first_part @
- tshift t_twice (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2,
- Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>)
+ "steps0 (Suc 0, Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n)) t_fourtimes stp
+ = (Suc t_fourtimes_len, Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))
+ \<Longrightarrow> steps0 (Suc 0 + length (t_wcode_main_first_part @
+ shift t_twice (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2,
+ Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
((t_wcode_main_first_part @
- tshift t_twice (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) @
- tshift t_fourtimes (length (t_wcode_main_first_part @
- tshift t_twice (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2) @ ([(L, 1), (L, 1)])) stp
- = (Suc t_fourtimes_len + length (t_wcode_main_first_part @
- tshift t_twice (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2,
- Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (4 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
-proof(rule_tac t_tshift_lemma, auto)
- assume "steps (Suc 0, Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_fourtimes stp =
- (Suc t_fourtimes_len, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires, Oc\<^bsup>Suc (4 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- thus "0 < stp"
- using t_fourtimes_len_gr
- apply(case_tac stp, simp_all add: steps.simps)
- done
-next
- show "Suc 0 \<le> length t_fourtimes div 2"
- apply(simp add: t_fourtimes_def shift_length tMp.simps)
- done
-next
- show "t_ncorrect (t_wcode_main_first_part @
- tshift t_twice (length t_wcode_main_first_part div 2) @
- [(L, Suc 0), (L, Suc 0)])"
- apply(simp add: t_ncorrect.simps t_wcode_main_first_part_def shift_length
- t_twice_def)
- using tm_even[of abc_twice]
- by arith
-next
- show "t_ncorrect t_fourtimes"
- apply(simp add: t_fourtimes_def steps.simps t_ncorrect.simps)
- using tm_even[of abc_fourtimes]
- by arith
-next
- show "t_ncorrect [(L, Suc 0), (L, Suc 0)]"
- apply(simp add: t_ncorrect.simps)
- done
-qed
+ shift t_twice (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) @
+ shift t_fourtimes (length (t_wcode_main_first_part @
+ shift t_twice (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2) @ ([(L, 1), (L, 1)])) stp
+ = ((Suc t_fourtimes_len) + length (t_wcode_main_first_part @
+ shift t_twice (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2,
+ Bk\<up>(ln) @ Bk # Bk # ires, Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))"
+apply(rule_tac tm_append_shift_append_steps, simp_all)
+apply(auto simp: t_wcode_main_first_part_def)
+done
+
lemma [simp]: "length t_wcode_main_first_part = 24"
apply(simp add: t_wcode_main_first_part_def)
done
lemma [simp]: "(26 + length t_twice) div 2 = (length t_twice) div 2 + 13"
-using tm_even[of abc_twice]
-apply(simp add: t_twice_def)
-done
-
-lemma [simp]: "((26 + length (tshift t_twice 12)) div 2)
- = (length (tshift t_twice 12) div 2 + 13)"
-using tm_even[of abc_twice]
+apply(simp add: t_twice_def t_twice_def)
+done
+
+lemma [simp]: "((26 + length (shift t_twice 12)) div 2)
+ = (length (shift t_twice 12) div 2 + 13)"
apply(simp add: t_twice_def)
done
-lemma [simp]: "t_twice_len + 14 = 14 + length (tshift t_twice 12) div 2"
-using tm_even[of abc_twice]
-apply(simp add: t_twice_def t_twice_len_def shift_length)
+lemma [simp]: "t_twice_len + 14 = 14 + length (shift t_twice 12) div 2"
+apply(simp add: t_twice_def t_twice_len_def)
done
lemma t_fourtimes_append:
"\<exists> stp ln rn.
- steps (Suc 0 + length (t_wcode_main_first_part @ tshift t_twice
+ steps0 (Suc 0 + length (t_wcode_main_first_part @ shift t_twice
(length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2,
- Bk # Bk # ires, Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>)
- ((t_wcode_main_first_part @ tshift t_twice (length t_wcode_main_first_part div 2) @
- [(L, 1), (L, 1)]) @ tshift t_fourtimes (t_twice_len + 13) @ [(L, 1), (L, 1)]) stp
- = (Suc t_fourtimes_len + length (t_wcode_main_first_part @ tshift t_twice
- (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2, Bk\<^bsup>ln\<^esup> @ Bk # Bk # ires,
- Oc\<^bsup>Suc (4 * rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ Bk # Bk # ires, Oc\<up>(Suc rs) @ Bk\<up>(n))
+ ((t_wcode_main_first_part @ shift t_twice (length t_wcode_main_first_part div 2) @
+ [(L, 1), (L, 1)]) @ shift t_fourtimes (t_twice_len + 13) @ [(L, 1), (L, 1)]) stp
+ = (Suc t_fourtimes_len + length (t_wcode_main_first_part @ shift t_twice
+ (length t_wcode_main_first_part div 2) @ [(L, 1), (L, 1)]) div 2, Bk\<up>(ln) @ Bk # Bk # ires,
+ Oc\<up>(Suc (4 * rs)) @ Bk\<up>(rn))"
using t_fourtimes_change_term_state[of ires rs n]
apply(erule_tac exE)
apply(erule_tac exE)
apply(erule_tac exE)
apply(drule_tac t_fourtimes_append_pre)
- apply(erule_tac exE)
- apply(rule_tac x = stpa in exI, rule_tac x = ln in exI, rule_tac x = rn in exI)
- apply(simp add: t_twice_len_def shift_length)
+ apply(rule_tac x = stp in exI, rule_tac x = ln in exI, rule_tac x = rn in exI)
+ apply(simp add: t_twice_len_def)
done
lemma t_wcode_main_len: "length t_wcode_main = length t_twice + length t_fourtimes + 28"
-apply(simp add: t_wcode_main_def shift_length)
-done
-
+apply(simp add: t_wcode_main_def)
+done
+
+lemma even_twice_len: "length t_twice mod 2 = 0"
+apply(auto simp: t_twice_def t_twice_compile_def)
+done
+
+lemma even_fourtimes_len: "length t_fourtimes mod 2 = 0"
+apply(auto simp: t_fourtimes_def t_fourtimes_compile_def)
+done
+
+lemma [simp]: "2 * (length t_twice div 2) = length t_twice"
+using even_twice_len
+by arith
+
+lemma [simp]: "2 * (length t_fourtimes div 2) = length t_fourtimes"
+using even_fourtimes_len
+by arith
+
+lemma [simp]: "fetch t_wcode_main (14 + length t_twice div 2 + t_fourtimes_len) Oc
+ = (L, Suc 0)"
+apply(subgoal_tac "14 = Suc 13")
+apply(simp only: fetch.simps add_Suc nth_of.simps t_wcode_main_def)
+apply(simp add:length_append length_shift Parity.two_times_even_div_two even_twice_len t_fourtimes_len_def)
+by arith
+
+lemma [simp]: "fetch t_wcode_main (14 + length t_twice div 2 + t_fourtimes_len) Bk
+ = (L, Suc 0)"
+apply(subgoal_tac "14 = Suc 13")
+apply(simp only: fetch.simps add_Suc nth_of.simps t_wcode_main_def)
+apply(simp add:length_append length_shift Parity.two_times_even_div_two even_twice_len t_fourtimes_len_def nth_append)
+by arith
+
lemma [simp]: "fetch t_wcode_main (14 + length t_twice div 2 + t_fourtimes_len) b
= (L, Suc 0)"
-using tm_even[of "abc_twice"] tm_even[of "abc_fourtimes"]
-apply(case_tac b)
-apply(simp_all only: fetch.simps)
-apply(auto simp: nth_of.simps t_wcode_main_len t_twice_len_def
- t_fourtimes_def t_twice_def t_fourtimes_def t_fourtimes_len_def)
-apply(auto simp: t_wcode_main_def t_wcode_main_first_part_def shift_length t_twice_def nth_append
- t_fourtimes_def)
+apply(case_tac b, simp_all)
done
lemma wcode_jump2:
- "\<exists> stp ln rn. steps (t_twice_len + 14 + t_fourtimes_len
- , Bk # Bk # Bk\<^bsup>lnb\<^esup> @ Oc # ires, Oc\<^bsup>Suc (4 * rs + 4)\<^esup> @ Bk\<^bsup>rnb\<^esup>) t_wcode_main stp =
- (Suc 0, Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires, Bk # Oc\<^bsup>Suc (4 * rs + 4)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ "\<exists> stp ln rn. steps0 (t_twice_len + 14 + t_fourtimes_len
+ , Bk # Bk # Bk\<up>(lnb) @ Oc # ires, Oc\<up>(Suc (4 * rs + 4)) @ Bk\<up>(rnb)) t_wcode_main stp =
+ (Suc 0, Bk # Bk\<up>(ln) @ Oc # ires, Bk # Oc\<up>(Suc (4 * rs + 4)) @ Bk\<up>(rn))"
apply(rule_tac x = "Suc 0" in exI)
-apply(simp add: steps.simps shift_length)
+apply(simp add: steps.simps)
apply(rule_tac x = lnb in exI, rule_tac x = rnb in exI)
-apply(simp add: tstep.simps new_tape.simps)
+apply(simp add: step.simps)
done
lemma wcode_fourtimes_case:
shows "\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # Oc # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (Suc 0, Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires, Bk # Oc\<^bsup>Suc (4*rs + 4)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (Suc 0, Bk # Bk\<up>(ln) @ Oc # ires, Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rn))"
proof -
have "\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # Oc # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (t_twice_len + 14, Bk # Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires, Oc\<^bsup>Suc (rs + 1)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (t_twice_len + 14, Bk # Bk # Bk\<up>(ln) @ Oc # ires, Oc\<up>(Suc (rs + 1)) @ Bk\<up>(rn))"
using wcode_fourtimes_case_first_correctness[of ires rs m n]
apply(simp add: wcode_fourtimes_case_inv.simps, auto)
apply(rule_tac x = na in exI, rule_tac x = ln in exI,
@@ -2178,12 +2184,12 @@
apply(simp)
done
from this obtain stpa lna rna where stp1:
- "steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # Oc # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stpa =
- (t_twice_len + 14, Bk # Bk # Bk\<^bsup>lna\<^esup> @ Oc # ires, Oc\<^bsup>Suc (rs + 1)\<^esup> @ Bk\<^bsup>rna\<^esup>)" by blast
- have "\<exists>stp ln rn. steps (t_twice_len + 14, Bk # Bk # Bk\<^bsup>lna\<^esup> @ Oc # ires, Oc\<^bsup>Suc (rs + 1)\<^esup> @ Bk\<^bsup>rna\<^esup>)
+ "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Oc # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stpa =
+ (t_twice_len + 14, Bk # Bk # Bk\<up>(lna) @ Oc # ires, Oc\<up>(Suc (rs + 1)) @ Bk\<up>(rna))" by blast
+ have "\<exists>stp ln rn. steps0 (t_twice_len + 14, Bk # Bk # Bk\<up>(lna) @ Oc # ires, Oc\<up>(Suc (rs + 1)) @ Bk\<up>(rna))
t_wcode_main stp =
- (t_twice_len + 14 + t_fourtimes_len, Bk # Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires, Oc\<^bsup>Suc (4*rs + 4)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- using t_fourtimes_append[of " Bk\<^bsup>lna\<^esup> @ Oc # ires" "rs + 1" rna]
+ (t_twice_len + 14 + t_fourtimes_len, Bk # Bk # Bk\<up>(ln) @ Oc # ires, Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rn))"
+ using t_fourtimes_append[of " Bk\<up>(lna) @ Oc # ires" "rs + 1" rna]
apply(erule_tac exE)
apply(erule_tac exE)
apply(erule_tac exE)
@@ -2191,24 +2197,24 @@
apply(rule_tac x = stp in exI,
rule_tac x = "ln + lna" in exI,
rule_tac x = rn in exI, simp)
- apply(simp add: exp_ind_def[THEN sym] exp_add[THEN sym])
+ apply(simp add: replicate_Suc[THEN sym] exp_add[THEN sym] del: replicate_Suc)
done
from this obtain stpb lnb rnb where stp2:
- "steps (t_twice_len + 14, Bk # Bk # Bk\<^bsup>lna\<^esup> @ Oc # ires, Oc\<^bsup>Suc (rs + 1)\<^esup> @ Bk\<^bsup>rna\<^esup>)
+ "steps0 (t_twice_len + 14, Bk # Bk # Bk\<up>(lna) @ Oc # ires, Oc\<up>(Suc (rs + 1)) @ Bk\<up>(rna))
t_wcode_main stpb =
- (t_twice_len + 14 + t_fourtimes_len, Bk # Bk # Bk\<^bsup>lnb\<^esup> @ Oc # ires, Oc\<^bsup>Suc (4*rs + 4)\<^esup> @ Bk\<^bsup>rnb\<^esup>)"
+ (t_twice_len + 14 + t_fourtimes_len, Bk # Bk # Bk\<up>(lnb) @ Oc # ires, Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rnb))"
by blast
- have "\<exists>stp ln rn. steps (t_twice_len + 14 + t_fourtimes_len,
- Bk # Bk # Bk\<^bsup>lnb\<^esup> @ Oc # ires, Oc\<^bsup>Suc (4*rs + 4)\<^esup> @ Bk\<^bsup>rnb\<^esup>)
+ have "\<exists>stp ln rn. steps0 (t_twice_len + 14 + t_fourtimes_len,
+ Bk # Bk # Bk\<up>(lnb) @ Oc # ires, Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rnb))
t_wcode_main stp =
- (Suc 0, Bk # Bk\<^bsup>ln\<^esup> @ Oc # ires, Bk # Oc\<^bsup>Suc (4*rs + 4)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ (Suc 0, Bk # Bk\<up>(ln) @ Oc # ires, Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rn))"
apply(rule wcode_jump2)
done
from this obtain stpc lnc rnc where stp3:
- "steps (t_twice_len + 14 + t_fourtimes_len,
- Bk # Bk # Bk\<^bsup>lnb\<^esup> @ Oc # ires, Oc\<^bsup>Suc (4*rs + 4)\<^esup> @ Bk\<^bsup>rnb\<^esup>)
+ "steps0 (t_twice_len + 14 + t_fourtimes_len,
+ Bk # Bk # Bk\<up>(lnb) @ Oc # ires, Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rnb))
t_wcode_main stpc =
- (Suc 0, Bk # Bk\<^bsup>lnc\<^esup> @ Oc # ires, Bk # Oc\<^bsup>Suc (4*rs + 4)\<^esup> @ Bk\<^bsup>rnc\<^esup>)"
+ (Suc 0, Bk # Bk\<up>(lnc) @ Oc # ires, Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rnc))"
by blast
from stp1 stp2 stp3 show "?thesis"
apply(rule_tac x = "stpa + stpb + stpc" in exI,
@@ -2222,15 +2228,15 @@
fun wcode_on_left_moving_3_B :: "bin_inv_t"
where
"wcode_on_left_moving_3_B ires rs (l, r) =
- (\<exists> ml mr rn. l = Bk\<^bsup>ml\<^esup> @ Oc # Bk # Bk # ires \<and>
- r = Bk\<^bsup>mr\<^esup> @ Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ (\<exists> ml mr rn. l = Bk\<up>(ml) @ Oc # Bk # Bk # ires \<and>
+ r = Bk\<up>(mr) @ Oc\<up>(Suc rs) @ Bk\<up>(rn) \<and>
ml + mr > Suc 0 \<and> mr > 0 )"
fun wcode_on_left_moving_3_O :: "bin_inv_t"
where
"wcode_on_left_moving_3_O ires rs (l, r) =
(\<exists> ln rn. l = Bk # Bk # ires \<and>
- r = Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ r = Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
fun wcode_on_left_moving_3 :: "bin_inv_t"
where
@@ -2242,19 +2248,19 @@
where
"wcode_on_checking_3 ires rs (l, r) =
(\<exists> ln rn. l = Bk # ires \<and>
- r = Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ r = Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
fun wcode_goon_checking_3 :: "bin_inv_t"
where
"wcode_goon_checking_3 ires rs (l, r) =
(\<exists> ln rn. l = ires \<and>
- r = Bk # Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ r = Bk # Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
fun wcode_stop :: "bin_inv_t"
where
"wcode_stop ires rs (l, r) =
(\<exists> ln rn. l = Bk # ires \<and>
- r = Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ r = Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
fun wcode_halt_case_inv :: "nat \<Rightarrow> bin_inv_t"
where
@@ -2265,7 +2271,7 @@
else if st = 7 then wcode_goon_checking_3 ires rs (l, r)
else False)"
-fun wcode_halt_case_state :: "t_conf \<Rightarrow> nat"
+fun wcode_halt_case_state :: "config \<Rightarrow> nat"
where
"wcode_halt_case_state (st, l, r) =
(if st = 1 then 5
@@ -2273,19 +2279,19 @@
else if st = 7 then 3
else 0)"
-fun wcode_halt_case_step :: "t_conf \<Rightarrow> nat"
+fun wcode_halt_case_step :: "config \<Rightarrow> nat"
where
"wcode_halt_case_step (st, l, r) =
(if st = 1 then length l
else 0)"
-fun wcode_halt_case_measure :: "t_conf \<Rightarrow> nat \<times> nat"
+fun wcode_halt_case_measure :: "config \<Rightarrow> nat \<times> nat"
where
"wcode_halt_case_measure (st, l, r) =
(wcode_halt_case_state (st, l, r),
wcode_halt_case_step (st, l, r))"
-definition wcode_halt_case_le :: "(t_conf \<times> t_conf) set"
+definition wcode_halt_case_le :: "(config \<times> config) set"
where "wcode_halt_case_le \<equiv> (inv_image lex_pair wcode_halt_case_measure)"
lemma wf_wcode_halt_case_le[intro]: "wf wcode_halt_case_le"
@@ -2301,13 +2307,15 @@
wcode_on_left_moving_3.simps wcode_stop.simps
lemma [simp]: "fetch t_wcode_main 7 Bk = (R, 0)"
-apply(simp add: fetch.simps t_wcode_main_def nth_append nth_of.simps
+apply(subgoal_tac "7 = Suc 6")
+apply(simp only: fetch.simps t_wcode_main_def nth_append nth_of.simps
t_wcode_main_first_part_def)
+apply(auto)
done
lemma [simp]: "wcode_on_left_moving_3 ires rs (b, []) = False"
apply(simp only: wcode_halt_invs)
-apply(simp add: exp_ind_def)
+apply(simp)
done
lemma [simp]: "wcode_on_checking_3 ires rs (b, []) = False"
@@ -2325,10 +2333,11 @@
apply(erule_tac exE)+
apply(case_tac ml, simp)
apply(rule_tac x = "mr - 2" in exI, rule_tac x = rn in exI)
-apply(case_tac mr, simp, simp add: exp_ind, simp add: exp_ind[THEN sym])
+apply(case_tac mr, simp, simp add: exp_ind del: replicate_Suc)
+apply(case_tac nat, simp, simp add: exp_ind del: replicate_Suc)
apply(rule_tac disjI1)
apply(rule_tac x = nat in exI, rule_tac x = "Suc mr" in exI,
- rule_tac x = rn in exI, simp add: exp_ind_def)
+ rule_tac x = rn in exI, simp)
apply(simp)
done
@@ -2345,7 +2354,7 @@
lemma [simp]: "wcode_on_left_moving_3 ires rs (b, Oc # list) \<Longrightarrow>
wcode_on_checking_3 ires rs (tl b, hd b # Oc # list)"
apply(simp add:wcode_halt_invs, auto)
-apply(case_tac [!] mr, simp_all add: exp_ind_def)
+apply(case_tac [!] mr, simp_all)
done
lemma [simp]: "wcode_on_checking_3 ires rs (b, Oc # list) = False"
@@ -2356,7 +2365,6 @@
apply(simp add: wcode_halt_invs, auto)
done
-
lemma [simp]: "wcode_on_checking_3 ires rs (b, Bk # list) \<Longrightarrow> b \<noteq> []"
apply(auto simp: wcode_halt_invs)
done
@@ -2373,12 +2381,12 @@
lemma t_halt_case_correctness:
shows "let P = (\<lambda> (st, l, r). st = 0) in
let Q = (\<lambda> (st, l, r). wcode_halt_case_inv st ires rs (l, r)) in
- let f = (\<lambda> stp. steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp) in
+ let f = (\<lambda> stp. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp) in
\<exists> n .P (f n) \<and> Q (f (n::nat))"
proof -
let ?P = "(\<lambda> (st, l, r). st = 0)"
let ?Q = "(\<lambda> (st, l, r). wcode_halt_case_inv st ires rs (l, r))"
- let ?f = "(\<lambda> stp. steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp)"
+ let ?f = "(\<lambda> stp. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp)"
have "\<exists> n. ?P (?f n) \<and> ?Q (?f (n::nat))"
proof(rule_tac halt_lemma2)
show "wf wcode_halt_case_le" by auto
@@ -2386,14 +2394,14 @@
show "\<forall> na. \<not> ?P (?f na) \<and> ?Q (?f na) \<longrightarrow>
?Q (?f (Suc na)) \<and> (?f (Suc na), ?f na) \<in> wcode_halt_case_le"
apply(rule_tac allI, rule_tac impI, case_tac "?f na")
- apply(simp add: tstep_red tstep.simps)
+ apply(simp add: step_red step.simps)
apply(case_tac c, simp, case_tac [2] aa)
- apply(simp_all split: if_splits add: new_tape.simps wcode_halt_case_le_def lex_pair_def)
+ apply(simp_all split: if_splits add: wcode_halt_case_le_def lex_pair_def)
done
next
show "?Q (?f 0)"
apply(simp add: steps.simps wcode_halt_invs)
- apply(rule_tac x = "Suc m" in exI, simp add: exp_ind_def)
+ apply(rule_tac x = "Suc m" in exI, simp)
apply(rule_tac x = "Suc 0" in exI, auto)
done
next
@@ -2407,20 +2415,19 @@
qed
declare wcode_halt_case_inv.simps[simp del]
-lemma [intro]: "\<exists> xs. (<rev list @ [aa::nat]> :: block list) = Oc # xs"
+lemma [intro]: "\<exists> xs. (<rev list @ [aa::nat]> :: cell list) = Oc # xs"
apply(case_tac "rev list", simp)
-apply(simp add: tape_of_nat_abv tape_of_nat_list.simps exp_ind_def)
-apply(case_tac list, simp, simp)
+apply(simp add: tape_of_nl_cons)
done
lemma wcode_halt_case:
- "\<exists>stp ln rn. steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>)
- t_wcode_main stp = (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n))
+ t_wcode_main stp = (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
using t_halt_case_correctness[of ires rs m n]
apply(simp)
apply(erule_tac exE)
-apply(case_tac "steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main na")
+apply(case_tac "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # Bk # ires,
+ Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main na")
apply(auto simp: wcode_halt_case_inv.simps wcode_stop.simps)
apply(rule_tac x = na in exI, rule_tac x = ln in exI,
rule_tac x = rn in exI, simp)
@@ -2430,20 +2437,28 @@
apply(simp add: bl_bin.simps)
done
+lemma [simp]: "bl_bin [Oc] = 1"
+apply(simp add: bl_bin.simps)
+done
+
+lemma [intro]: "2 * 2 ^ a = Suc (Suc (2 * bl_bin (Oc \<up> a)))"
+apply(induct a, auto simp: bl_bin.simps)
+done
+declare replicate_Suc[simp del]
+
lemma t_wcode_main_lemma_pre:
"\<lbrakk>args \<noteq> []; lm = <args::nat list>\<rbrakk> \<Longrightarrow>
- \<exists> stp ln rn. steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ rev lm @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main
+ \<exists> stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(m) @ rev lm @ Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main
stp
- = (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin lm + rs * 2^(length lm - 1) \<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ = (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin lm + rs * 2^(length lm - 1) ) @ Bk\<up>(rn))"
proof(induct "length args" arbitrary: args lm rs m n, simp)
fix x args lm rs m n
assume ind:
"\<And>args lm rs m n.
\<lbrakk>x = length args; (args::nat list) \<noteq> []; lm = <args>\<rbrakk>
\<Longrightarrow> \<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ rev lm @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin lm + rs * 2 ^ (length lm - 1)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
-
+ steps0 (Suc 0, Bk # Bk\<up>(m) @ rev lm @ Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin lm + rs * 2 ^ (length lm - 1)) @ Bk\<up>(rn))"
and h: "Suc x = length args" "(args::nat list) \<noteq> []" "lm = <args>"
from h have "\<exists> (a::nat) xs. args = xs @ [a]"
apply(rule_tac x = "last args" in exI)
@@ -2452,103 +2467,104 @@
from this obtain a xs where "args = xs @ [a]" by blast
from h and this show
"\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ rev lm @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin lm + rs * 2 ^ (length lm - 1)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ steps0 (Suc 0, Bk # Bk\<up>(m) @ rev lm @ Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin lm + rs * 2 ^ (length lm - 1)) @ Bk\<up>(rn))"
proof(case_tac "xs::nat list", simp)
show "\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ rev (<a>) @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<a>) + rs * 2 ^ a\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ steps0 (Suc 0, Bk # Bk \<up> m @ Oc \<up> Suc a @ Bk # Bk # ires, Bk # Oc \<up> Suc rs @ Bk \<up> n) t_wcode_main stp =
+ (0, Bk # ires, Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> (bl_bin (Oc \<up> Suc a) + rs * 2 ^ a) @ Bk \<up> rn)"
proof(induct "a" arbitrary: m n rs ires, simp)
fix m n rs ires
- show "\<exists>stp ln rn. steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>)
- t_wcode_main stp = (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin [Oc] + rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- apply(simp add: bl_bin_one)
- apply(rule_tac wcode_halt_case)
+ show "\<exists>stp ln rn.
+ steps0 (Suc 0, Bk # Bk \<up> m @ Oc # Bk # Bk # ires, Bk # Oc \<up> Suc rs @ Bk \<up> n) t_wcode_main stp =
+ (0, Bk # ires, Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> Suc rs @ Bk \<up> rn)"
+ apply(rule_tac wcode_halt_case)
done
next
fix a m n rs ires
- assume ind2:
+ assume ind2:
"\<And>m n rs ires.
- \<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ rev (<a>) @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<a>) + rs * 2 ^ a\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- show "\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ rev (<Suc a>) @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<Suc a>) + rs * 2 ^ Suc a\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ \<exists>stp ln rn.
+ steps0 (Suc 0, Bk # Bk \<up> m @ Oc \<up> Suc a @ Bk # Bk # ires, Bk # Oc \<up> Suc rs @ Bk \<up> n) t_wcode_main stp =
+ (0, Bk # ires, Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> (bl_bin (Oc \<up> Suc a) + rs * 2 ^ a) @ Bk \<up> rn)"
+ show " \<exists>stp ln rn.
+ steps0 (Suc 0, Bk # Bk \<up> m @ Oc \<up> Suc (Suc a) @ Bk # Bk # ires, Bk # Oc \<up> Suc rs @ Bk \<up> n) t_wcode_main stp =
+ (0, Bk # ires, Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> (bl_bin (Oc \<up> Suc (Suc a)) + rs * 2 ^ Suc a) @ Bk \<up> rn)"
proof -
have "\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ rev (<Suc a>) @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (Suc 0, Bk # Bk\<^bsup>ln\<^esup> @ rev (<a>) @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc (2 * rs + 2)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ steps0 (Suc 0, Bk # Bk\<up>(m) @ rev (<Suc a>) @ Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (Suc 0, Bk # Bk\<up>(ln) @ rev (<a>) @ Bk # Bk # ires, Bk # Oc\<up>(Suc (2 * rs + 2)) @ Bk\<up>(rn))"
apply(simp add: tape_of_nat)
- using wcode_double_case[of m "Oc\<^bsup>a\<^esup> @ Bk # Bk # ires" rs n]
- apply(simp add: exp_ind_def)
+ using wcode_double_case[of m "Oc\<up>(a) @ Bk # Bk # ires" rs n]
+ apply(simp add: replicate_Suc)
done
from this obtain stpa lna rna where stp1:
- "steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ rev (<Suc a>) @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stpa =
- (Suc 0, Bk # Bk\<^bsup>lna\<^esup> @ rev (<a>) @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc (2 * rs + 2)\<^esup> @ Bk\<^bsup>rna\<^esup>)" by blast
+ "steps0 (Suc 0, Bk # Bk\<up>(m) @ rev (<Suc a>) @ Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stpa =
+ (Suc 0, Bk # Bk\<up>(lna) @ rev (<a>) @ Bk # Bk # ires, Bk # Oc\<up>(Suc (2 * rs + 2)) @ Bk\<up>(rna))" by blast
moreover have
"\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>lna\<^esup> @ rev (<a>) @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc (2 * rs + 2)\<^esup> @ Bk\<^bsup>rna\<^esup>) t_wcode_main stp =
- (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<a>) + (2*rs + 2) * 2 ^ a\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- using ind2[of lna ires "2*rs + 2" rna] by simp
+ steps0 (Suc 0, Bk # Bk\<up>(lna) @ rev (<a::nat>) @ Bk # Bk # ires, Bk # Oc\<up>(Suc (2 * rs + 2)) @ Bk\<up>(rna)) t_wcode_main stp =
+ (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin (<a>) + (2*rs + 2) * 2 ^ a) @ Bk\<up>(rn))"
+ using ind2[of lna ires "2*rs + 2" rna] by(simp add: tape_of_nl_abv tape_of_nat_abv)
from this obtain stpb lnb rnb where stp2:
- "steps (Suc 0, Bk # Bk\<^bsup>lna\<^esup> @ rev (<a>) @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc (2 * rs + 2)\<^esup> @ Bk\<^bsup>rna\<^esup>) t_wcode_main stpb =
- (0, Bk # ires, Bk # Oc # Bk\<^bsup>lnb\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<a>) + (2*rs + 2) * 2 ^ a\<^esup> @ Bk\<^bsup>rnb\<^esup>)"
+ "steps0 (Suc 0, Bk # Bk\<up>(lna) @ rev (<a>) @ Bk # Bk # ires, Bk # Oc\<up>(Suc (2 * rs + 2)) @ Bk\<up>(rna)) t_wcode_main stpb =
+ (0, Bk # ires, Bk # Oc # Bk\<up>(lnb) @ Bk # Bk # Oc\<up>(bl_bin (<a>) + (2*rs + 2) * 2 ^ a) @ Bk\<up>(rnb))"
by blast
from stp1 and stp2 show "?thesis"
apply(rule_tac x = "stpa + stpb" in exI,
- rule_tac x = lnb in exI, rule_tac x = rnb in exI, simp)
- apply(simp add: steps_add bl_bin_nat_Suc exponent_def)
+ rule_tac x = lnb in exI, rule_tac x = rnb in exI, simp add: tape_of_nat_abv)
+ apply(simp add: bl_bin.simps replicate_Suc)
+ apply(auto)
done
qed
qed
next
fix aa list
assume g: "Suc x = length args" "args \<noteq> []" "lm = <args>" "args = xs @ [a::nat]" "xs = (aa::nat) # list"
- thus "\<exists>stp ln rn. steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ rev lm @ Bk # Bk # ires, Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin lm + rs * 2 ^ (length lm - 1)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ thus "\<exists>stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(m) @ rev lm @ Bk # Bk # ires, Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin lm + rs * 2 ^ (length lm - 1)) @ Bk\<up>(rn))"
proof(induct a arbitrary: m n rs args lm, simp_all add: tape_of_nl_rev,
simp only: tape_of_nl_cons_app1, simp)
fix m n rs args lm
have "\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # rev (<(aa::nat) # list>) @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (Suc 0, Bk # Bk\<^bsup>ln\<^esup> @ rev (<aa # list>) @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc (4*rs + 4)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # rev (<(aa::nat) # list>) @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (Suc 0, Bk # Bk\<up>(ln) @ rev (<aa # list>) @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rn))"
proof(simp add: tape_of_nl_rev)
have "\<exists> xs. (<rev list @ [aa]>) = Oc # xs" by auto
from this obtain xs where "(<rev list @ [aa]>) = Oc # xs" ..
thus "\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # <rev list @ [aa]> @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (Suc 0, Bk # Bk\<^bsup>ln\<^esup> @ <rev list @ [aa]> @ Bk # Bk # ires, Bk # Oc\<^bsup>5 + 4 * rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # <rev list @ [aa]> @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (Suc 0, Bk # Bk\<up>(ln) @ <rev list @ [aa]> @ Bk # Bk # ires, Bk # Oc\<up>(5 + 4 * rs) @ Bk\<up>(rn))"
apply(simp)
using wcode_fourtimes_case[of m "xs @ Bk # Bk # ires" rs n]
apply(simp)
done
qed
from this obtain stpa lna rna where stp1:
- "steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # rev (<aa # list>) @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stpa =
- (Suc 0, Bk # Bk\<^bsup>lna\<^esup> @ rev (<aa # list>) @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc (4*rs + 4)\<^esup> @ Bk\<^bsup>rna\<^esup>)" by blast
+ "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # rev (<aa # list>) @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stpa =
+ (Suc 0, Bk # Bk\<up>(lna) @ rev (<aa # list>) @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rna))" by blast
from g have
- "\<exists> stp ln rn. steps (Suc 0, Bk # Bk\<^bsup>lna\<^esup> @ rev (<(aa::nat) # list>) @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc (4*rs + 4)\<^esup> @ Bk\<^bsup>rna\<^esup>) t_wcode_main stp = (0, Bk # ires,
- Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<aa#list>)+ (4*rs + 4) * 2^(length (<aa#list>) - 1) \<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ "\<exists> stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(lna) @ rev (<(aa::nat) # list>) @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rna)) t_wcode_main stp = (0, Bk # ires,
+ Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin (<aa#list>)+ (4*rs + 4) * 2^(length (<aa#list>) - 1) ) @ Bk\<up>(rn))"
apply(rule_tac args = "(aa::nat)#list" in ind, simp_all)
done
from this obtain stpb lnb rnb where stp2:
- "steps (Suc 0, Bk # Bk\<^bsup>lna\<^esup> @ rev (<(aa::nat) # list>) @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc (4*rs + 4)\<^esup> @ Bk\<^bsup>rna\<^esup>) t_wcode_main stpb = (0, Bk # ires,
- Bk # Oc # Bk\<^bsup>lnb\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<aa#list>)+ (4*rs + 4) * 2^(length (<aa#list>) - 1) \<^esup> @ Bk\<^bsup>rnb\<^esup>)"
+ "steps0 (Suc 0, Bk # Bk\<up>(lna) @ rev (<(aa::nat) # list>) @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc (4*rs + 4)) @ Bk\<up>(rna)) t_wcode_main stpb = (0, Bk # ires,
+ Bk # Oc # Bk\<up>(lnb) @ Bk # Bk # Oc\<up>(bl_bin (<aa#list>)+ (4*rs + 4) * 2^(length (<aa#list>) - 1) ) @ Bk\<up>(rnb))"
by blast
from stp1 and stp2 and h
show "\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc # Bk # <rev list @ [aa]> @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk #
- Bk # Oc\<^bsup>bl_bin (Oc\<^bsup>Suc aa\<^esup> @ Bk # <list @ [0]>) + rs * (2 * 2 ^ (aa + length (<list @ [0]>)))\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc # Bk # <rev list @ [aa]> @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk #
+ Bk # Oc\<up>(bl_bin (Oc\<up>(Suc aa) @ Bk # <list @ [0]>) + rs * (2 * 2 ^ (aa + length (<list @ [0]>)))) @ Bk\<up>(rn))"
apply(rule_tac x = "stpa + stpb" in exI, rule_tac x = lnb in exI,
rule_tac x = rnb in exI, simp add: steps_add tape_of_nl_rev)
done
@@ -2558,53 +2574,53 @@
"\<And> m n rs args lm.
\<lbrakk>lm = <aa # list @ [ab]>; args = aa # list @ [ab]\<rbrakk>
\<Longrightarrow> \<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ <ab # rev list @ [aa]> @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk #
- Bk # Oc\<^bsup>bl_bin (<aa # list @ [ab]>) + rs * 2 ^ (length (<aa # list @ [ab]>) - Suc 0)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ steps0 (Suc 0, Bk # Bk\<up>(m) @ <ab # rev list @ [aa]> @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk #
+ Bk # Oc\<up>(bl_bin (<aa # list @ [ab]>) + rs * 2 ^ (length (<aa # list @ [ab]>) - Suc 0)) @ Bk\<up>(rn))"
and k: "args = aa # list @ [Suc ab]" "lm = <aa # list @ [Suc ab]>"
show "\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ <Suc ab # rev list @ [aa]> @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (0, Bk # ires,Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk #
- Bk # Oc\<^bsup>bl_bin (<aa # list @ [Suc ab]>) + rs * 2 ^ (length (<aa # list @ [Suc ab]>) - Suc 0)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ steps0 (Suc 0, Bk # Bk\<up>(m) @ <Suc ab # rev list @ [aa]> @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (0, Bk # ires,Bk # Oc # Bk\<up>(ln) @ Bk #
+ Bk # Oc\<up>(bl_bin (<aa # list @ [Suc ab]>) + rs * 2 ^ (length (<aa # list @ [Suc ab]>) - Suc 0)) @ Bk\<up>(rn))"
proof(simp add: tape_of_nl_cons_app1)
have "\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc\<^bsup>Suc (Suc ab)\<^esup> @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
- Bk # Oc # Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp
- = (Suc 0, Bk # Bk\<^bsup>ln\<^esup> @ Oc\<^bsup>Suc ab\<^esup> @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc (2*rs + 2)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- using wcode_double_case[of m "Oc\<^bsup>ab\<^esup> @ Bk # <rev list @ [aa]> @ Bk # Bk # ires"
+ steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc\<up>(Suc (Suc ab)) @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
+ Bk # Oc # Oc\<up>(rs) @ Bk\<up>(n)) t_wcode_main stp
+ = (Suc 0, Bk # Bk\<up>(ln) @ Oc\<up>(Suc ab) @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc (2*rs + 2)) @ Bk\<up>(rn))"
+ using wcode_double_case[of m "Oc\<up>(ab) @ Bk # <rev list @ [aa]> @ Bk # Bk # ires"
rs n]
- apply(simp add: exp_ind_def)
+ apply(simp add: replicate_Suc)
done
from this obtain stpa lna rna where stp1:
- "steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc\<^bsup>Suc (Suc ab)\<^esup> @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
- Bk # Oc # Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stpa
- = (Suc 0, Bk # Bk\<^bsup>lna\<^esup> @ Oc\<^bsup>Suc ab\<^esup> @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc (2*rs + 2)\<^esup> @ Bk\<^bsup>rna\<^esup>)" by blast
+ "steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc\<up>(Suc (Suc ab)) @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
+ Bk # Oc # Oc\<up>(rs) @ Bk\<up>(n)) t_wcode_main stpa
+ = (Suc 0, Bk # Bk\<up>(lna) @ Oc\<up>(Suc ab) @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc (2*rs + 2)) @ Bk\<up>(rna))" by blast
from k have
- "\<exists> stp ln rn. steps (Suc 0, Bk # Bk\<^bsup>lna\<^esup> @ <ab # rev list @ [aa]> @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc (2*rs + 2)\<^esup> @ Bk\<^bsup>rna\<^esup>) t_wcode_main stp
- = (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk #
- Bk # Oc\<^bsup>bl_bin (<aa # list @ [ab]> ) + (2*rs + 2)* 2^(length (<aa # list @ [ab]>) - Suc 0)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ "\<exists> stp ln rn. steps0 (Suc 0, Bk # Bk\<up>(lna) @ <ab # rev list @ [aa]> @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc (2*rs + 2)) @ Bk\<up>(rna)) t_wcode_main stp
+ = (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk #
+ Bk # Oc\<up>(bl_bin (<aa # list @ [ab]> ) + (2*rs + 2)* 2^(length (<aa # list @ [ab]>) - Suc 0)) @ Bk\<up>(rn))"
apply(rule_tac ind2, simp_all)
done
from this obtain stpb lnb rnb where stp2:
- "steps (Suc 0, Bk # Bk\<^bsup>lna\<^esup> @ <ab # rev list @ [aa]> @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc (2*rs + 2)\<^esup> @ Bk\<^bsup>rna\<^esup>) t_wcode_main stpb
- = (0, Bk # ires, Bk # Oc # Bk\<^bsup>lnb\<^esup> @ Bk #
- Bk # Oc\<^bsup>bl_bin (<aa # list @ [ab]> ) + (2*rs + 2)* 2^(length (<aa # list @ [ab]>) - Suc 0)\<^esup> @ Bk\<^bsup>rnb\<^esup>)"
+ "steps0 (Suc 0, Bk # Bk\<up>(lna) @ <ab # rev list @ [aa]> @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc (2*rs + 2)) @ Bk\<up>(rna)) t_wcode_main stpb
+ = (0, Bk # ires, Bk # Oc # Bk\<up>(lnb) @ Bk #
+ Bk # Oc\<up>(bl_bin (<aa # list @ [ab]> ) + (2*rs + 2)* 2^(length (<aa # list @ [ab]>) - Suc 0)) @ Bk\<up>(rnb))"
by blast
from stp1 and stp2 show
"\<exists>stp ln rn.
- steps (Suc 0, Bk # Bk\<^bsup>m\<^esup> @ Oc\<^bsup>Suc (Suc ab)\<^esup> @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
- Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>) t_wcode_main stp =
- (0, Bk # ires, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk #
- Oc\<^bsup>bl_bin (Oc\<^bsup>Suc aa\<^esup> @ Bk # <list @ [Suc ab]>) + rs * (2 * 2 ^ (aa + length (<list @ [Suc ab]>)))\<^esup>
- @ Bk\<^bsup>rn\<^esup>)"
+ steps0 (Suc 0, Bk # Bk\<up>(m) @ Oc\<up>(Suc (Suc ab)) @ Bk # <rev list @ [aa]> @ Bk # Bk # ires,
+ Bk # Oc\<up>(Suc rs) @ Bk\<up>(n)) t_wcode_main stp =
+ (0, Bk # ires, Bk # Oc # Bk\<up>(ln) @ Bk # Bk #
+ Oc\<up>(bl_bin (Oc\<up>(Suc aa) @ Bk # <list @ [Suc ab]>) + rs * (2 * 2 ^ (aa + length (<list @ [Suc ab]>))))
+ @ Bk\<up>(rn))"
apply(rule_tac x = "stpa + stpb" in exI, rule_tac x = lnb in exI,
- rule_tac x = rnb in exI, simp add: steps_add tape_of_nl_cons_app1 exp_ind_def)
+ rule_tac x = rnb in exI, simp add: steps_add tape_of_nl_cons_app1 replicate_Suc)
done
qed
qed
@@ -2612,10 +2628,7 @@
qed
-
-(* turing_shift can be used*)
-term t_wcode_main
-definition t_wcode_prepare :: "tprog"
+definition t_wcode_prepare :: "instr list"
where
"t_wcode_prepare \<equiv>
[(W1, 2), (L, 1), (L, 3), (R, 2), (R, 4), (W0, 3),
@@ -2626,33 +2639,33 @@
where
"wprepare_add_one m lm (l, r) =
(\<exists> rn. l = [] \<and>
- (r = <m # lm> @ Bk\<^bsup>rn\<^esup> \<or>
- r = Bk # <m # lm> @ Bk\<^bsup>rn\<^esup>))"
+ (r = <m # lm> @ Bk\<up>(rn) \<or>
+ r = Bk # <m # lm> @ Bk\<up>(rn)))"
fun wprepare_goto_first_end :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
"wprepare_goto_first_end m lm (l, r) =
- (\<exists> ml mr rn. l = Oc\<^bsup>ml\<^esup> \<and>
- r = Oc\<^bsup>mr\<^esup> @ Bk # <lm> @ Bk\<^bsup>rn\<^esup> \<and>
+ (\<exists> ml mr rn. l = Oc\<up>(ml) \<and>
+ r = Oc\<up>(mr) @ Bk # <lm> @ Bk\<up>(rn) \<and>
ml + mr = Suc (Suc m))"
fun wprepare_erase :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
"wprepare_erase m lm (l, r) =
- (\<exists> rn. l = Oc\<^bsup>Suc m\<^esup> \<and>
- tl r = Bk # <lm> @ Bk\<^bsup>rn\<^esup>)"
+ (\<exists> rn. l = Oc\<up>(Suc m) \<and>
+ tl r = Bk # <lm> @ Bk\<up>(rn))"
fun wprepare_goto_start_pos_B :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
"wprepare_goto_start_pos_B m lm (l, r) =
- (\<exists> rn. l = Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = Bk # <lm> @ Bk\<^bsup>rn\<^esup>)"
+ (\<exists> rn. l = Bk # Oc\<up>(Suc m) \<and>
+ r = Bk # <lm> @ Bk\<up>(rn))"
fun wprepare_goto_start_pos_O :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
"wprepare_goto_start_pos_O m lm (l, r) =
- (\<exists> rn. l = Bk # Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = <lm> @ Bk\<^bsup>rn\<^esup>)"
+ (\<exists> rn. l = Bk # Bk # Oc\<up>(Suc m) \<and>
+ r = <lm> @ Bk\<up>(rn))"
fun wprepare_goto_start_pos :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
@@ -2663,15 +2676,15 @@
fun wprepare_loop_start_on_rightmost :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
"wprepare_loop_start_on_rightmost m lm (l, r) =
- (\<exists> rn mr. rev l @ r = Oc\<^bsup>Suc m\<^esup> @ Bk # Bk # <lm> @ Bk\<^bsup>rn\<^esup> \<and> l \<noteq> [] \<and>
- r = Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ (\<exists> rn mr. rev l @ r = Oc\<up>(Suc m) @ Bk # Bk # <lm> @ Bk\<up>(rn) \<and> l \<noteq> [] \<and>
+ r = Oc\<up>(mr) @ Bk\<up>(rn))"
fun wprepare_loop_start_in_middle :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
"wprepare_loop_start_in_middle m lm (l, r) =
(\<exists> rn (mr:: nat) (lm1::nat list).
- rev l @ r = Oc\<^bsup>Suc m\<^esup> @ Bk # Bk # <lm> @ Bk\<^bsup>rn\<^esup> \<and> l \<noteq> [] \<and>
- r = Oc\<^bsup>mr\<^esup> @ Bk # <lm1> @ Bk\<^bsup>rn\<^esup> \<and> lm1 \<noteq> [])"
+ rev l @ r = Oc\<up>(Suc m) @ Bk # Bk # <lm> @ Bk\<up>(rn) \<and> l \<noteq> [] \<and>
+ r = Oc\<up>(mr) @ Bk # <lm1> @ Bk\<up>(rn) \<and> lm1 \<noteq> [])"
fun wprepare_loop_start :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
@@ -2681,16 +2694,16 @@
fun wprepare_loop_goon_on_rightmost :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
"wprepare_loop_goon_on_rightmost m lm (l, r) =
- (\<exists> rn. l = Bk # <rev lm> @ Bk # Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = Bk\<^bsup>rn\<^esup>)"
+ (\<exists> rn. l = Bk # <rev lm> @ Bk # Bk # Oc\<up>(Suc m) \<and>
+ r = Bk\<up>(rn))"
fun wprepare_loop_goon_in_middle :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
"wprepare_loop_goon_in_middle m lm (l, r) =
(\<exists> rn (mr:: nat) (lm1::nat list).
- rev l @ r = Oc\<^bsup>Suc m\<^esup> @ Bk # Bk # <lm> @ Bk\<^bsup>rn\<^esup> \<and> l \<noteq> [] \<and>
- (if lm1 = [] then r = Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup>
- else r = Oc\<^bsup>mr\<^esup> @ Bk # <lm1> @ Bk\<^bsup>rn\<^esup>) \<and> mr > 0)"
+ rev l @ r = Oc\<up>(Suc m) @ Bk # Bk # <lm> @ Bk\<up>(rn) \<and> l \<noteq> [] \<and>
+ (if lm1 = [] then r = Oc\<up>(mr) @ Bk\<up>(rn)
+ else r = Oc\<up>(mr) @ Bk # <lm1> @ Bk\<up>(rn)) \<and> mr > 0)"
fun wprepare_loop_goon :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
@@ -2701,14 +2714,14 @@
fun wprepare_add_one2 :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
"wprepare_add_one2 m lm (l, r) =
- (\<exists> rn. l = Bk # Bk # <rev lm> @ Bk # Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- (r = [] \<or> tl r = Bk\<^bsup>rn\<^esup>))"
+ (\<exists> rn. l = Bk # Bk # <rev lm> @ Bk # Bk # Oc\<up>(Suc m) \<and>
+ (r = [] \<or> tl r = Bk\<up>(rn)))"
fun wprepare_stop :: "nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
"wprepare_stop m lm (l, r) =
- (\<exists> rn. l = Bk # <rev lm> @ Bk # Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = Bk # Oc # Bk\<^bsup>rn\<^esup>)"
+ (\<exists> rn. l = Bk # <rev lm> @ Bk # Bk # Oc\<up>(Suc m) \<and>
+ r = Bk # Oc # Bk\<up>(rn))"
fun wprepare_inv :: "nat \<Rightarrow> nat \<Rightarrow> nat list \<Rightarrow> tape \<Rightarrow> bool"
where
@@ -2723,14 +2736,14 @@
else if st = 7 then wprepare_add_one2 m lm (l, r)
else False)"
-fun wprepare_stage :: "t_conf \<Rightarrow> nat"
+fun wprepare_stage :: "config \<Rightarrow> nat"
where
"wprepare_stage (st, l, r) =
(if st \<ge> 1 \<and> st \<le> 4 then 3
else if st = 5 \<or> st = 6 then 2
else 1)"
-fun wprepare_state :: "t_conf \<Rightarrow> nat"
+fun wprepare_state :: "config \<Rightarrow> nat"
where
"wprepare_state (st, l, r) =
(if st = 1 then 4
@@ -2740,7 +2753,7 @@
else if st = 7 then 2
else 0)"
-fun wprepare_step :: "t_conf \<Rightarrow> nat"
+fun wprepare_step :: "config \<Rightarrow> nat"
where
"wprepare_step (st, l, r) =
(if st = 1 then (if hd r = Oc then Suc (length l)
@@ -2755,14 +2768,14 @@
else 1)
else 0)"
-fun wcode_prepare_measure :: "t_conf \<Rightarrow> nat \<times> nat \<times> nat"
+fun wcode_prepare_measure :: "config \<Rightarrow> nat \<times> nat \<times> nat"
where
"wcode_prepare_measure (st, l, r) =
(wprepare_stage (st, l, r),
wprepare_state (st, l, r),
wprepare_step (st, l, r))"
-definition wcode_prepare_le :: "(t_conf \<times> t_conf) set"
+definition wcode_prepare_le :: "(config \<times> config) set"
where "wcode_prepare_le \<equiv> (inv_image lex_triple wcode_prepare_measure)"
lemma [intro]: "wf lex_pair"
@@ -2770,7 +2783,7 @@
lemma wf_wcode_prepare_le[intro]: "wf wcode_prepare_le"
by(auto intro:wf_inv_image simp: wcode_prepare_le_def
- recursive.lex_triple_def)
+ lex_triple_def)
declare wprepare_add_one.simps[simp del] wprepare_goto_first_end.simps[simp del]
wprepare_erase.simps[simp del] wprepare_goto_start_pos.simps[simp del]
@@ -2808,45 +2821,56 @@
done
lemma [simp]: "fetch t_wcode_prepare 4 Bk = (R, 4)"
-apply(simp add: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(subgoal_tac "4 = Suc 3")
+apply(simp_all only: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(auto)
done
lemma [simp]: "fetch t_wcode_prepare 4 Oc = (R, 5)"
-apply(simp add: fetch.simps t_wcode_prepare_def nth_of.simps)
-done
+apply(subgoal_tac "4 = Suc 3")
+apply(simp_all only: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(auto)
+done
+
lemma [simp]: "fetch t_wcode_prepare 5 Oc = (R, 5)"
-apply(simp add: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(subgoal_tac "5 = Suc 4")
+apply(simp_all only: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(auto)
done
lemma [simp]: "fetch t_wcode_prepare 5 Bk = (R, 6)"
-apply(simp add: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(subgoal_tac "5 = Suc 4")
+apply(simp_all only: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(auto)
done
lemma [simp]: "fetch t_wcode_prepare 6 Oc = (R, 5)"
-apply(simp add: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(subgoal_tac "6 = Suc 5")
+apply(simp_all only: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(auto)
done
lemma [simp]: "fetch t_wcode_prepare 6 Bk = (R, 7)"
-apply(simp add: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(subgoal_tac "6 = Suc 5")
+apply(simp_all only: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(auto)
done
lemma [simp]: "fetch t_wcode_prepare 7 Oc = (L, 0)"
-apply(simp add: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(subgoal_tac "7 = Suc 6")
+apply(simp_all only: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(auto)
done
lemma [simp]: "fetch t_wcode_prepare 7 Bk = (W1, 7)"
-apply(simp add: fetch.simps t_wcode_prepare_def nth_of.simps)
-done
-
-lemma tape_of_nl_not_null: "lm \<noteq> [] \<Longrightarrow> <lm::nat list> \<noteq> []"
-apply(case_tac lm, auto)
-apply(case_tac list, auto simp: tape_of_nl_abv tape_of_nat_list.simps exp_ind_def)
+apply(subgoal_tac "7 = Suc 6")
+apply(simp_all only: fetch.simps t_wcode_prepare_def nth_of.simps)
+apply(auto)
done
lemma [simp]: "lm \<noteq> [] \<Longrightarrow> wprepare_add_one m lm (b, []) = False"
apply(simp add: wprepare_invs)
-apply(simp add: tape_of_nl_not_null)
done
lemma [simp]: "lm \<noteq> [] \<Longrightarrow> wprepare_goto_first_end m lm (b, []) = False"
@@ -2857,19 +2881,20 @@
apply(simp add: wprepare_invs)
done
-
-
lemma [simp]: "lm \<noteq> [] \<Longrightarrow> wprepare_goto_start_pos m lm (b, []) = False"
-apply(simp add: wprepare_invs tape_of_nl_not_null)
+apply(simp add: wprepare_invs)
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_start m lm (b, [])\<rbrakk> \<Longrightarrow> b \<noteq> []"
-apply(simp add: wprepare_invs tape_of_nl_not_null, auto)
-done
+apply(simp add: wprepare_invs)
+done
+
+lemma rev_eq: "rev xs = rev ys \<Longrightarrow> xs = ys"
+by auto
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_start m lm (b, [])\<rbrakk> \<Longrightarrow>
wprepare_loop_goon m lm (Bk # b, [])"
-apply(simp only: wprepare_invs tape_of_nl_not_null)
+apply(simp only: wprepare_invs)
apply(erule_tac disjE)
apply(rule_tac disjI2)
apply(simp add: wprepare_loop_start_on_rightmost.simps
@@ -2878,50 +2903,50 @@
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_goon m lm (b, [])\<rbrakk> \<Longrightarrow> b \<noteq> []"
-apply(simp only: wprepare_invs tape_of_nl_not_null, auto)
+apply(simp only: wprepare_invs, auto)
done
lemma [simp]:"\<lbrakk>lm \<noteq> []; wprepare_loop_goon m lm (b, [])\<rbrakk> \<Longrightarrow>
wprepare_add_one2 m lm (Bk # b, [])"
-apply(simp only: wprepare_invs tape_of_nl_not_null, auto split: if_splits)
-apply(case_tac mr, simp, simp add: exp_ind_def)
+apply(simp only: wprepare_invs, auto split: if_splits)
done
lemma [simp]: "wprepare_add_one2 m lm (b, []) \<Longrightarrow> b \<noteq> []"
-apply(simp only: wprepare_invs tape_of_nl_not_null, auto)
+apply(simp only: wprepare_invs, auto)
done
lemma [simp]: "wprepare_add_one2 m lm (b, []) \<Longrightarrow> wprepare_add_one2 m lm (b, [Oc])"
-apply(simp only: wprepare_invs tape_of_nl_not_null, auto)
+apply(simp only: wprepare_invs, auto)
done
lemma [simp]: "Bk # list = <(m::nat) # lm> @ ys = False"
-apply(case_tac lm, auto simp: tape_of_nl_abv tape_of_nat_list.simps exp_ind_def)
+apply(case_tac lm, auto simp: tape_of_nl_cons replicate_Suc)
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_add_one m lm (b, Bk # list)\<rbrakk>
\<Longrightarrow> (b = [] \<longrightarrow> wprepare_goto_first_end m lm ([], Oc # list)) \<and>
(b \<noteq> [] \<longrightarrow> wprepare_goto_first_end m lm (b, Oc # list))"
-apply(simp only: wprepare_invs, auto)
-apply(rule_tac x = 0 in exI, simp add: exp_ind_def)
-apply(case_tac lm, simp, simp add: tape_of_nl_abv tape_of_nat_list.simps exp_ind_def)
-apply(rule_tac x = rn in exI, simp)
+apply(simp only: wprepare_invs)
+apply(auto simp: tape_of_nl_cons split: if_splits)
+apply(rule_tac x = 0 in exI, simp add: replicate_Suc)
+apply(case_tac lm, simp, simp add: tape_of_nl_abv tape_of_nat_list.simps replicate_Suc)
done
lemma [simp]: "wprepare_goto_first_end m lm (b, Bk # list) \<Longrightarrow> b \<noteq> []"
-apply(simp only: wprepare_invs tape_of_nl_not_null, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
-done
+apply(simp only: wprepare_invs , auto simp: replicate_Suc)
+done
+
+declare replicate_Suc[simp]
lemma [simp]: "wprepare_goto_first_end m lm (b, Bk # list) \<Longrightarrow>
wprepare_erase m lm (tl b, hd b # Bk # list)"
-apply(simp only: wprepare_invs tape_of_nl_not_null, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
-apply(case_tac mr, auto simp: exp_ind_def)
+apply(simp only: wprepare_invs, auto)
+apply(case_tac mr, simp_all)
+apply(case_tac mr, auto)
done
lemma [simp]: "wprepare_erase m lm (b, Bk # list) \<Longrightarrow> b \<noteq> []"
-apply(simp only: wprepare_invs exp_ind_def, auto)
+apply(simp only: wprepare_invs, auto)
done
lemma [simp]: "wprepare_erase m lm (b, Bk # list) \<Longrightarrow>
@@ -2932,18 +2957,16 @@
lemma [simp]: "\<lbrakk>wprepare_add_one m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> list \<noteq> []"
apply(simp only: wprepare_invs)
apply(case_tac lm, simp_all add: tape_of_nl_abv
- tape_of_nat_list.simps exp_ind_def, auto)
+ tape_of_nat_list.simps, auto)
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_goto_first_end m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> list \<noteq> []"
apply(simp only: wprepare_invs, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
-apply(simp add: tape_of_nl_not_null)
+apply(case_tac mr, simp_all)
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_goto_first_end m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> b \<noteq> []"
apply(simp only: wprepare_invs, auto)
-apply(case_tac mr, simp_all add: exp_ind_def tape_of_nl_not_null)
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_erase m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> list \<noteq> []"
@@ -2951,14 +2974,13 @@
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_erase m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> b \<noteq> []"
-apply(simp only: wprepare_invs, auto simp: exp_ind_def)
+apply(simp only: wprepare_invs, auto)
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_goto_start_pos m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> list \<noteq> []"
apply(simp only: wprepare_invs, auto)
-apply(simp add: tape_of_nl_not_null)
apply(case_tac lm, simp, case_tac list)
-apply(simp_all add: tape_of_nl_abv tape_of_nat_list.simps exp_ind_def)
+apply(simp_all add: tape_of_nl_abv tape_of_nat_list.simps)
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_goto_start_pos m lm (b, Bk # list)\<rbrakk> \<Longrightarrow> b \<noteq> []"
@@ -2975,10 +2997,10 @@
(list \<noteq> [] \<longrightarrow> wprepare_add_one2 m lm (Bk # b, list))"
apply(simp only: wprepare_invs, simp)
apply(case_tac list, simp_all split: if_splits, auto)
-apply(case_tac [1-3] mr, simp_all add: exp_ind_def)
-apply(case_tac mr, simp_all add: exp_ind_def tape_of_nl_not_null)
-apply(case_tac [1-2] mr, simp_all add: exp_ind_def)
-apply(case_tac rn, simp, case_tac nat, auto simp: exp_ind_def)
+apply(case_tac [1-3] mr, simp_all add: )
+apply(case_tac mr, simp_all)
+apply(case_tac [1-2] mr, simp_all add: )
+apply(case_tac rn, simp, case_tac nat, auto simp: )
done
lemma [simp]: "wprepare_add_one2 m lm (b, Bk # list) \<Longrightarrow> b \<noteq> []"
@@ -2996,21 +3018,19 @@
(b \<noteq> [] \<longrightarrow> wprepare_goto_first_end m lm (Oc # b, list))"
apply(simp only: wprepare_invs, auto)
apply(rule_tac x = 1 in exI, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
-apply(case_tac ml, simp_all add: exp_ind_def)
-apply(rule_tac x = rn in exI, simp)
-apply(rule_tac x = "Suc ml" in exI, simp_all add: exp_ind_def)
+apply(case_tac mr, simp_all add: )
+apply(case_tac ml, simp_all add: )
+apply(rule_tac x = "Suc ml" in exI, simp_all add: )
apply(rule_tac x = "mr - 1" in exI, simp)
-apply(case_tac mr, simp_all add: exp_ind_def, auto)
done
lemma [simp]: "wprepare_erase m lm (b, Oc # list) \<Longrightarrow> b \<noteq> []"
-apply(simp only: wprepare_invs, auto simp: exp_ind_def)
+apply(simp only: wprepare_invs, auto simp: )
done
lemma [simp]: "wprepare_erase m lm (b, Oc # list)
\<Longrightarrow> wprepare_erase m lm (b, Bk # list)"
-apply(simp only:wprepare_invs, auto simp: exp_ind_def)
+apply(simp only:wprepare_invs, auto simp: )
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_goto_start_pos m lm (b, Bk # list)\<rbrakk>
@@ -3022,26 +3042,25 @@
lemma [simp]: "wprepare_loop_start m lm (b, aa) \<Longrightarrow> b \<noteq> []"
apply(simp only:wprepare_invs, auto)
done
-lemma [elim]: "Bk # list = Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<Longrightarrow> \<exists>rn. list = Bk\<^bsup>rn\<^esup>"
+lemma [elim]: "Bk # list = Oc\<up>(mr) @ Bk\<up>(rn) \<Longrightarrow> \<exists>rn. list = Bk\<up>(rn)"
apply(case_tac mr, simp_all)
-apply(case_tac rn, simp_all add: exp_ind_def, auto)
+apply(case_tac rn, simp_all)
done
lemma rev_equal_iff: "x = y \<Longrightarrow> rev x = rev y"
by simp
lemma tape_of_nl_false1:
- "lm \<noteq> [] \<Longrightarrow> rev b @ [Bk] \<noteq> Bk\<^bsup>ln\<^esup> @ Oc # Oc\<^bsup>m\<^esup> @ Bk # Bk # <lm::nat list>"
+ "lm \<noteq> [] \<Longrightarrow> rev b @ [Bk] \<noteq> Bk\<up>(ln) @ Oc # Oc\<up>(m) @ Bk # Bk # <lm::nat list>"
apply(auto)
apply(drule_tac rev_equal_iff, simp add: tape_of_nl_rev)
apply(case_tac "rev lm")
-apply(case_tac [2] list, auto simp: tape_of_nl_abv tape_of_nat_list.simps exp_ind_def)
+apply(case_tac [2] list, auto simp: tape_of_nl_abv tape_of_nat_list.simps )
done
lemma [simp]: "wprepare_loop_start_in_middle m lm (b, [Bk]) = False"
apply(simp add: wprepare_loop_start_in_middle.simps, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
-apply(case_tac lm1, simp, simp add: tape_of_nl_not_null)
+apply(case_tac mr, simp_all add: )
done
declare wprepare_loop_start_in_middle.simps[simp del]
@@ -3059,39 +3078,39 @@
apply(simp only: wprepare_invs, simp)
apply(simp add: wprepare_loop_goon_on_rightmost.simps
wprepare_loop_start_on_rightmost.simps, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
+apply(case_tac mr, simp_all add: )
apply(rule_tac rev_eq)
apply(simp add: tape_of_nl_rev)
-apply(simp add: exp_ind_def[THEN sym] exp_ind)
+apply(simp add: exp_ind replicate_Suc[THEN sym] del: replicate_Suc)
done
lemma [simp]: "wprepare_loop_start_on_rightmost m lm (b, Bk # a # lista)
\<Longrightarrow> wprepare_loop_goon_in_middle m lm (Bk # b, a # lista) = False"
apply(auto simp: wprepare_loop_start_on_rightmost.simps
wprepare_loop_goon_in_middle.simps)
-apply(case_tac [!] mr, simp_all add: exp_ind_def)
+apply(case_tac [!] mr, simp_all)
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_start_on_rightmost m lm (b, Bk # a # lista)\<rbrakk>
\<Longrightarrow> wprepare_loop_goon_on_rightmost m lm (Bk # b, a # lista)"
apply(simp only: wprepare_loop_start_on_rightmost.simps
wprepare_loop_goon_on_rightmost.simps, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
+apply(case_tac mr, simp_all add: )
apply(simp add: tape_of_nl_rev)
-apply(simp add: exp_ind_def[THEN sym] exp_ind)
+apply(simp add: replicate_Suc[THEN sym] exp_ind del: replicate_Suc)
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_loop_start_in_middle m lm (b, Bk # a # lista)\<rbrakk>
\<Longrightarrow> wprepare_loop_goon_on_rightmost m lm (Bk # b, a # lista) = False"
apply(simp add: wprepare_loop_start_in_middle.simps
wprepare_loop_goon_on_rightmost.simps, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
+apply(case_tac mr, simp_all add: )
apply(case_tac "lm1::nat list", simp_all, case_tac list, simp)
-apply(simp add: tape_of_nl_abv tape_of_nat_list.simps tape_of_nat_abv exp_ind_def)
-apply(case_tac [!] rna, simp_all add: exp_ind_def)
-apply(case_tac mr, simp_all add: exp_ind_def)
+apply(simp add: tape_of_nl_abv tape_of_nat_list.simps tape_of_nat_abv )
+apply(case_tac [!] rna, simp_all add: )
+apply(case_tac mr, simp_all add: )
apply(case_tac lm1, simp, case_tac list, simp)
-apply(simp_all add: tape_of_nl_abv tape_of_nat_list.simps exp_ind_def tape_of_nat_abv)
+apply(simp_all add: tape_of_nl_abv tape_of_nat_list.simps tape_of_nat_abv)
done
lemma [simp]:
@@ -3100,7 +3119,7 @@
apply(simp add: wprepare_loop_start_in_middle.simps
wprepare_loop_goon_in_middle.simps, auto)
apply(rule_tac x = rn in exI, simp)
-apply(case_tac mr, simp_all add: exp_ind_def)
+apply(case_tac mr, simp_all add: )
apply(case_tac lm1, simp)
apply(rule_tac x = "Suc aa" in exI, simp)
apply(rule_tac x = list in exI)
@@ -3137,15 +3156,14 @@
wprepare_loop_start_on_rightmost m lm (Oc # b, list)"
apply(simp add: wprepare_loop_start_on_rightmost.simps, auto)
apply(rule_tac x = rn in exI, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
-apply(case_tac rn, auto simp: exp_ind_def)
+apply(case_tac mr, simp_all add: )
done
lemma [simp]: "wprepare_loop_start_in_middle m lm (b, Oc # list) \<Longrightarrow>
wprepare_loop_start_in_middle m lm (Oc # b, list)"
apply(simp add: wprepare_loop_start_in_middle.simps, auto)
apply(rule_tac x = rn in exI, auto)
-apply(case_tac mr, simp, simp add: exp_ind_def)
+apply(case_tac mr, simp, simp add: )
apply(rule_tac x = nat in exI, simp)
apply(rule_tac x = lm1 in exI, simp)
done
@@ -3170,20 +3188,20 @@
lemma [simp]: "wprepare_loop_goon_on_rightmost m lm (b, Oc # list) = False"
apply(simp add: wprepare_loop_goon_on_rightmost.simps)
done
-lemma wprepare_loop1: "\<lbrakk>rev b @ Oc\<^bsup>mr\<^esup> = Oc\<^bsup>Suc m\<^esup> @ Bk # Bk # <lm>;
- b \<noteq> []; 0 < mr; Oc # list = Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup>\<rbrakk>
+lemma wprepare_loop1: "\<lbrakk>rev b @ Oc\<up>(mr) = Oc\<up>(Suc m) @ Bk # Bk # <lm>;
+ b \<noteq> []; 0 < mr; Oc # list = Oc\<up>(mr) @ Bk\<up>(rn)\<rbrakk>
\<Longrightarrow> wprepare_loop_start_on_rightmost m lm (Oc # b, list)"
apply(simp add: wprepare_loop_start_on_rightmost.simps)
apply(rule_tac x = rn in exI, simp)
-apply(case_tac mr, simp, simp add: exp_ind_def, auto)
-done
-
-lemma wprepare_loop2: "\<lbrakk>rev b @ Oc\<^bsup>mr\<^esup> @ Bk # <a # lista> = Oc\<^bsup>Suc m\<^esup> @ Bk # Bk # <lm>;
- b \<noteq> []; Oc # list = Oc\<^bsup>mr\<^esup> @ Bk # <(a::nat) # lista> @ Bk\<^bsup>rn\<^esup>\<rbrakk>
+apply(case_tac mr, simp, simp)
+done
+
+lemma wprepare_loop2: "\<lbrakk>rev b @ Oc\<up>(mr) @ Bk # <a # lista> = Oc\<up>(Suc m) @ Bk # Bk # <lm>;
+ b \<noteq> []; Oc # list = Oc\<up>(mr) @ Bk # <(a::nat) # lista> @ Bk\<up>(rn)\<rbrakk>
\<Longrightarrow> wprepare_loop_start_in_middle m lm (Oc # b, list)"
apply(simp add: wprepare_loop_start_in_middle.simps)
apply(rule_tac x = rn in exI, simp)
-apply(case_tac mr, simp_all add: exp_ind_def)
+apply(case_tac mr, simp_all add: )
apply(rule_tac x = nat in exI, simp)
apply(rule_tac x = "a#lista" in exI, simp)
done
@@ -3212,7 +3230,7 @@
apply(auto simp: wprepare_goto_start_pos.simps
wprepare_loop_start_on_rightmost.simps)
apply(rule_tac x = rn in exI, simp)
-apply(simp add: tape_of_nat_abv tape_of_nat_list.simps exp_ind_def, auto)
+apply(simp add: replicate_Suc[THEN sym] exp_ind del: replicate_Suc)
done
lemma [simp]: "wprepare_goto_start_pos m (a # aa # listaa) (b, Oc # list)
@@ -3220,8 +3238,9 @@
apply(auto simp: wprepare_goto_start_pos.simps
wprepare_loop_start_in_middle.simps)
apply(rule_tac x = rn in exI, simp)
-apply(simp add: tape_of_nl_abv tape_of_nat_list.simps exp_ind_def)
+apply(simp add: exp_ind[THEN sym])
apply(rule_tac x = a in exI, rule_tac x = "aa#listaa" in exI, simp)
+apply(simp add: tape_of_nl_cons)
done
lemma [simp]: "\<lbrakk>lm \<noteq> []; wprepare_goto_start_pos m lm (b, Oc # list)\<rbrakk>
@@ -3246,12 +3265,12 @@
assumes h: "lm \<noteq> []"
shows "let P = (\<lambda> (st, l, r). st = 0) in
let Q = (\<lambda> (st, l, r). wprepare_inv st m lm (l, r)) in
- let f = (\<lambda> stp. steps (Suc 0, [], (<m # lm>)) t_wcode_prepare stp) in
+ let f = (\<lambda> stp. steps0 (Suc 0, [], (<m # lm>)) t_wcode_prepare stp) in
\<exists> n .P (f n) \<and> Q (f n)"
proof -
let ?P = "(\<lambda> (st, l, r). st = 0)"
let ?Q = "(\<lambda> (st, l, r). wprepare_inv st m lm (l, r))"
- let ?f = "(\<lambda> stp. steps (Suc 0, [], (<m # lm>)) t_wcode_prepare stp)"
+ let ?f = "(\<lambda> stp. steps0 (Suc 0, [], (<m # lm>)) t_wcode_prepare stp)"
have "\<exists> n. ?P (?f n) \<and> ?Q (?f n)"
proof(rule_tac halt_lemma2)
show "wf wcode_prepare_le" by auto
@@ -3260,11 +3279,9 @@
?Q (?f (Suc n)) \<and> (?f (Suc n), ?f n) \<in> wcode_prepare_le"
using h
apply(rule_tac allI, rule_tac impI, case_tac "?f n",
- simp add: tstep_red tstep.simps)
+ simp add: step_red step.simps)
apply(case_tac c, simp, case_tac [2] aa)
- apply(simp_all add: wprepare_inv.simps wcode_prepare_le_def new_tape.simps
- lex_triple_def lex_pair_def
-
+ apply(simp_all add: wprepare_inv.simps wcode_prepare_le_def lex_triple_def lex_pair_def
split: if_splits)
apply(simp_all add: start_2_goon start_2_start
add_one_2_add_one add_one_2_stop)
@@ -3284,35 +3301,27 @@
done
qed
-lemma [intro]: "t_correct t_wcode_prepare"
-apply(simp add: t_correct.simps t_wcode_prepare_def iseven_def)
-apply(rule_tac x = 7 in exI, simp)
-done
-
-lemma twice_len_even: "length (tm_of abc_twice) mod 2 = 0"
-apply(simp add: tm_even)
-done
-
-lemma fourtimes_len_even: "length (tm_of abc_fourtimes) mod 2 = 0"
-apply(simp add: tm_even)
-done
-
+lemma [intro]: "tm_wf (t_wcode_prepare, 0)"
+apply(simp add:tm_wf.simps t_wcode_prepare_def)
+done
+
+(*
lemma t_correct_termi: "t_correct tp \<Longrightarrow>
list_all (\<lambda>(acn, st). (st \<le> Suc (length tp div 2))) (change_termi_state tp)"
apply(auto simp: t_correct.simps List.list_all_length)
apply(erule_tac x = n in allE, simp)
apply(case_tac "tp!n", auto simp: change_termi_state.simps split: if_splits)
done
-
+*)
lemma t_correct_shift:
"list_all (\<lambda>(acn, st). (st \<le> y)) tp \<Longrightarrow>
- list_all (\<lambda>(acn, st). (st \<le> y + off)) (tshift tp off) "
-apply(auto simp: t_correct.simps List.list_all_length)
-apply(erule_tac x = n in allE, simp add: shift_length)
-apply(case_tac "tp!n", auto simp: tshift.simps)
-done
-
+ list_all (\<lambda>(acn, st). (st \<le> y + off)) (shift tp off) "
+apply(auto simp: List.list_all_length)
+apply(erule_tac x = n in allE, simp add: length_shift)
+apply(case_tac "tp!n", auto simp: shift.simps)
+done
+(*
lemma [intro]:
"t_correct (tm_of abc_twice @ tMp (Suc 0)
(start_of twice_ly (length abc_twice) - Suc 0))"
@@ -3325,177 +3334,237 @@
apply(rule_tac t_compiled_correct, simp_all)
apply(simp add: fourtimes_ly_def)
done
-
-
-lemma [intro]: "t_correct t_wcode_main"
-apply(auto simp: t_wcode_main_def t_correct.simps shift_length
- t_twice_def t_fourtimes_def)
+*)
+
+lemma [intro]: "(28 + (length t_twice_compile + length t_fourtimes_compile)) mod 2 = 0"
+apply(auto simp: t_twice_compile_def t_fourtimes_compile_def)
+by arith
+
+lemma [elim]: "(a, b) \<in> set t_wcode_main_first_part \<Longrightarrow>
+ b \<le> (28 + (length t_twice_compile + length t_fourtimes_compile)) div 2"
+apply(auto simp: t_wcode_main_first_part_def t_twice_def)
+done
+
+
+
+lemma tm_wf_change_termi: "tm_wf (tp, 0) \<Longrightarrow>
+ list_all (\<lambda>(acn, st). (st \<le> Suc (length tp div 2))) (adjust tp)"
+apply(auto simp: tm_wf.simps List.list_all_length)
+apply(case_tac "tp!n", auto simp: adjust.simps split: if_splits)
+apply(erule_tac x = "(a, b)" in ballE, auto)
+by (metis in_set_conv_nth)
+
+lemma tm_wf_shift:
+ "list_all (\<lambda>(acn, st). (st \<le> y)) tp \<Longrightarrow>
+ list_all (\<lambda>(acn, st). (st \<le> y + off)) (shift tp off) "
+apply(auto simp: tm_wf.simps List.list_all_length)
+apply(erule_tac x = n in allE, simp add: length_shift)
+apply(case_tac "tp!n", auto simp: shift.simps)
+done
+
+declare length_tp'[simp del]
+
+lemma [simp]: "length (mopup (Suc 0)) = 16"
+apply(auto simp: mopup.simps)
+done
+
+lemma [elim]: "(a, b) \<in> set (shift (turing_basic.adjust t_twice_compile) 12) \<Longrightarrow>
+ b \<le> (28 + (length t_twice_compile + length t_fourtimes_compile)) div 2"
+apply(simp add: t_twice_compile_def t_fourtimes_compile_def)
proof -
- show "iseven (60 + (length (tm_of abc_twice) +
- length (tm_of abc_fourtimes)))"
- using twice_len_even fourtimes_len_even
- apply(auto simp: iseven_def)
- apply(rule_tac x = "30 + q + qa" in exI, simp)
- done
-next
- show " list_all (\<lambda>(acn, s). s \<le> (60 + (length (tm_of abc_twice) +
- length (tm_of abc_fourtimes))) div 2) t_wcode_main_first_part"
- apply(auto simp: t_wcode_main_first_part_def shift_length t_twice_def)
- done
-next
- have "list_all (\<lambda>(acn, s). s \<le> Suc (length (tm_of abc_twice @ tMp (Suc 0)
- (start_of twice_ly (length abc_twice) - Suc 0)) div 2))
- (change_termi_state (tm_of abc_twice @ tMp (Suc 0)
- (start_of twice_ly (length abc_twice) - Suc 0)))"
- apply(rule_tac t_correct_termi, auto)
+ assume g: "(a, b) \<in> set (shift (turing_basic.adjust (tm_of abc_twice @ shift (mopup (Suc 0)) (length (tm_of abc_twice) div 2))) 12)"
+ moreover have "length (tm_of abc_twice) mod 2 = 0" by auto
+ moreover have "length (tm_of abc_fourtimes) mod 2 = 0" by auto
+ ultimately have "list_all (\<lambda>(acn, st). (st \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2))
+ (shift (turing_basic.adjust t_twice_compile) 12)"
+ proof(auto simp: mod_ex1)
+ fix q qa
+ assume h: "length (tm_of abc_twice) = 2 * q" "length (tm_of abc_fourtimes) = 2 * qa"
+ hence "list_all (\<lambda>(acn, st). st \<le> (18 + (q + qa)) + 12) (shift (turing_basic.adjust t_twice_compile) 12)"
+ proof(rule_tac tm_wf_shift t_twice_compile_def)
+ have "list_all (\<lambda>(acn, st). st \<le> Suc (length t_twice_compile div 2)) (adjust t_twice_compile)"
+ by(rule_tac tm_wf_change_termi, auto)
+ thus "list_all (\<lambda>(acn, st). st \<le> 18 + (q + qa)) (turing_basic.adjust t_twice_compile)"
+ using h
+ apply(simp add: t_twice_compile_def, auto simp: List.list_all_length)
+ done
+ qed
+ thus "list_all (\<lambda>(acn, st). st \<le> 30 + (q + qa)) (shift (turing_basic.adjust t_twice_compile) 12)"
+ by simp
+ qed
+ thus "b \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2"
+ using g
+ apply(auto simp:t_twice_compile_def)
+ apply(simp add: Ball_set[THEN sym])
+ apply(erule_tac x = "(a, b)" in ballE, simp, simp)
done
- hence "list_all (\<lambda>(acn, s). s \<le> Suc (length (tm_of abc_twice @ tMp (Suc 0)
- (start_of twice_ly (length abc_twice) - Suc 0)) div 2) + 12)
- (tshift (change_termi_state (tm_of abc_twice @ tMp (Suc 0)
- (start_of twice_ly (length abc_twice) - Suc 0))) 12)"
- apply(rule_tac t_correct_shift, simp)
- done
- thus "list_all (\<lambda>(acn, s). s \<le>
- (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2)
- (tshift (change_termi_state (tm_of abc_twice @ tMp (Suc 0)
- (start_of twice_ly (length abc_twice) - Suc 0))) 12)"
- apply(simp)
- apply(simp add: list_all_length, auto)
- done
-next
- have "list_all (\<lambda>(acn, s). s \<le> Suc (length (tm_of abc_fourtimes @ tMp (Suc 0)
- (start_of fourtimes_ly (length abc_fourtimes) - Suc 0)) div 2))
- (change_termi_state (tm_of abc_fourtimes @ tMp (Suc 0)
- (start_of fourtimes_ly (length abc_fourtimes) - Suc 0))) "
- apply(rule_tac t_correct_termi, auto)
- done
- hence "list_all (\<lambda>(acn, s). s \<le> Suc (length (tm_of abc_fourtimes @ tMp (Suc 0)
- (start_of fourtimes_ly (length abc_fourtimes) - Suc 0)) div 2) + (t_twice_len + 13))
- (tshift (change_termi_state (tm_of abc_fourtimes @ tMp (Suc 0)
- (start_of fourtimes_ly (length abc_fourtimes) - Suc 0))) (t_twice_len + 13))"
- apply(rule_tac t_correct_shift, simp)
- done
- thus "list_all (\<lambda>(acn, s). s \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2)
- (tshift (change_termi_state (tm_of abc_fourtimes @ tMp (Suc 0)
- (start_of fourtimes_ly (length abc_fourtimes) - Suc 0))) (t_twice_len + 13))"
- apply(simp add: t_twice_len_def t_twice_def)
- using twice_len_even fourtimes_len_even
- apply(auto simp: list_all_length)
+qed
+
+lemma [elim]: "(a, b) \<in> set (shift (turing_basic.adjust t_fourtimes_compile) (t_twice_len + 13))
+ \<Longrightarrow> b \<le> (28 + (length t_twice_compile + length t_fourtimes_compile)) div 2"
+apply(simp add: t_twice_compile_def t_fourtimes_compile_def t_twice_len_def)
+proof -
+ assume g: "(a, b) \<in> set (shift (turing_basic.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0))
+ (length (tm_of abc_fourtimes) div 2))) (length t_twice div 2 + 13))"
+ moreover have "length (tm_of abc_twice) mod 2 = 0" by auto
+ moreover have "length (tm_of abc_fourtimes) mod 2 = 0" by auto
+ ultimately have "list_all (\<lambda>(acn, st). (st \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2))
+ (shift (turing_basic.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0))
+ (length (tm_of abc_fourtimes) div 2))) (length t_twice div 2 + 13))"
+ proof(auto simp: mod_ex1 t_twice_def t_twice_compile_def)
+ fix q qa
+ assume h: "length (tm_of abc_twice) = 2 * q" "length (tm_of abc_fourtimes) = 2 * qa"
+ hence "list_all (\<lambda>(acn, st). st \<le> (9 + qa + (21 + q)))
+ (shift (turing_basic.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa)) (21 + q))"
+ proof(rule_tac tm_wf_shift t_twice_compile_def)
+ have "list_all (\<lambda>(acn, st). st \<le> Suc (length (tm_of abc_fourtimes @ shift
+ (mopup (Suc 0)) qa) div 2)) (adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa))"
+ apply(rule_tac tm_wf_change_termi)
+ using wf_fourtimes h
+ apply(simp add: t_fourtimes_compile_def)
+ done
+ thus "list_all (\<lambda>(acn, st). st \<le> 9 + qa) ((turing_basic.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa)))"
+ using h
+ apply(simp)
+ done
+ qed
+ thus "list_all (\<lambda>(acn, st). st \<le> 30 + (q + qa)) (shift (turing_basic.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa)) (21 + q))"
+ apply(subgoal_tac "qa + q = q + qa")
+ apply(simp, simp)
+ done
+ qed
+ thus "b \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2"
+ using g
+ apply(simp add: Ball_set[THEN sym])
+ apply(erule_tac x = "(a, b)" in ballE, simp, simp)
done
qed
-lemma [intro]: "t_correct (t_wcode_prepare |+| t_wcode_main)"
-apply(auto intro: t_correct_add)
+lemma [intro]: "tm_wf (t_wcode_main, 0)"
+apply(auto simp: t_wcode_main_def tm_wf.simps
+ t_twice_def t_fourtimes_def del: List.list_all_iff)
+done
+
+declare tm_comp.simps[simp del]
+lemma tm_wf_comp: "\<lbrakk>tm_wf (A, 0); tm_wf (B, 0)\<rbrakk> \<Longrightarrow> tm_wf (A |+| B, 0)"
+apply(auto simp: tm_wf.simps shift.simps adjust.simps tm_comp_length
+ tm_comp.simps)
+done
+
+lemma [intro]: "tm_wf (t_wcode_prepare |+| t_wcode_main, 0)"
+apply(rule_tac tm_wf_comp, auto)
done
lemma prepare_mainpart_lemma:
"args \<noteq> [] \<Longrightarrow>
- \<exists> stp ln rn. steps (Suc 0, [], <m # args>) (t_wcode_prepare |+| t_wcode_main) stp
- = (0, Bk # Oc\<^bsup>Suc m\<^esup>, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<args>)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ \<exists> stp ln rn. steps0 (Suc 0, [], <m # args>) (t_wcode_prepare |+| t_wcode_main) stp
+ = (0, Bk # Oc\<up>(Suc m), Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin (<args>)) @ Bk\<up>(rn))"
proof -
- let ?P1 = "\<lambda> (l, r). l = [] \<and> r = <m # args>"
- let ?Q1 = "\<lambda> (l, r). wprepare_stop m args (l, r)"
+ let ?P1 = "(\<lambda> (l, r). (l::cell list) = [] \<and> r = <m # args>)"
+ let ?Q1 = "(\<lambda> (l, r). wprepare_stop m args (l, r))"
let ?P2 = ?Q1
- let ?Q2 = "\<lambda> (l, r). (\<exists> ln rn. l = Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<args>)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ let ?Q2 = "(\<lambda> (l, r). (\<exists> ln rn. l = Bk # Oc\<up>(Suc m) \<and>
+ r = Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin (<args>)) @ Bk\<up>(rn)))"
let ?P3 = "\<lambda> tp. False"
assume h: "args \<noteq> []"
- have "?P1 \<turnstile>-> \<lambda> tp. (\<exists> stp tp'. steps (Suc 0, tp)
- (t_wcode_prepare |+| t_wcode_main) stp = (0, tp') \<and> ?Q2 tp')"
- proof(rule_tac turing_merge.t_merge_halt[of t_wcode_prepare t_wcode_main ?P1 ?P2 ?P3 ?P3 ?Q1 ?Q2],
- auto simp: turing_merge_def)
- show "\<exists>stp. case steps (Suc 0, [], <m # args>) t_wcode_prepare stp of (st, tp')
- \<Rightarrow> st = 0 \<and> wprepare_stop m args tp'"
- using wprepare_correctness[of args m] h
- apply(simp, auto)
- apply(rule_tac x = n in exI, simp add: wprepare_inv.simps)
- done
+ have "{?P1} t_wcode_prepare |+| t_wcode_main {?Q2}"
+ proof(rule_tac Hoare_plus_halt)
+ show "?Q1 \<mapsto> ?P2"
+ by(simp add: assert_imp_def)
+ next
+ show "tm_wf (t_wcode_prepare, 0)"
+ by auto
+ next
+ show "{?P1} t_wcode_prepare {?Q1}"
+ proof(rule_tac HoareI, auto)
+ show "\<exists>n. is_final (steps0 (Suc 0, [], <m # args>) t_wcode_prepare n) \<and>
+ wprepare_stop m args holds_for steps0 (Suc 0, [], <m # args>) t_wcode_prepare n"
+ using wprepare_correctness[of args m] h
+ apply(auto)
+ apply(rule_tac x = n in exI, simp add: wprepare_inv.simps)
+ done
+ qed
next
- fix a b
- assume "wprepare_stop m args (a, b)"
- thus "\<exists>stp. case steps (Suc 0, a, b) t_wcode_main stp of
- (st, tp') \<Rightarrow> (st = 0) \<and> (case tp' of (l, r) \<Rightarrow> l = Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- (\<exists>ln rn. r = Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<args>)\<^esup> @ Bk\<^bsup>rn\<^esup>))"
- proof(simp only: wprepare_stop.simps, erule_tac exE)
+ show "{?P2} t_wcode_main {?Q2}"
+ proof(rule_tac HoareI, auto)
+ fix l r
+ assume "wprepare_stop m args (l, r)"
+ thus "\<exists>n. is_final (steps0 (Suc 0, l, r) t_wcode_main n) \<and>
+ (\<lambda>(l, r). l = Bk # Oc # Oc \<up> m \<and> (\<exists>ln rn. r = Bk # Oc # Bk \<up> ln @
+ Bk # Bk # Oc \<up> bl_bin (<args>) @ Bk \<up> rn)) holds_for steps0 (Suc 0, l, r) t_wcode_main n"
+ proof(auto simp: wprepare_stop.simps)
fix rn
- assume "a = Bk # <rev args> @ Bk # Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- b = Bk # Oc # Bk\<^bsup>rn\<^esup>"
- thus "?thesis"
- using t_wcode_main_lemma_pre[of "args" "<args>" 0 "Oc\<^bsup>Suc m\<^esup>" 0 rn] h
- apply(simp)
- apply(erule_tac exE)+
- apply(rule_tac x = stp in exI, simp add: tape_of_nl_rev, auto)
+ show " \<exists>n. is_final (steps0 (Suc 0, Bk # <rev args> @ Bk # Bk # Oc # Oc \<up> m, Bk # Oc # Bk \<up> rn) t_wcode_main n) \<and>
+ (\<lambda>(l, r). l = Bk # Oc # Oc \<up> m \<and>
+ (\<exists>ln rn. r = Bk # Oc # Bk \<up> ln @
+ Bk # Bk # Oc \<up> bl_bin (<args>) @
+ Bk \<up> rn)) holds_for steps0 (Suc 0, Bk # <rev args> @ Bk # Bk # Oc # Oc \<up> m, Bk # Oc # Bk \<up> rn) t_wcode_main n"
+ using t_wcode_main_lemma_pre[of "args" "<args>" 0 "Oc\<up>(Suc m)" 0 rn] h
+ apply(auto simp: tape_of_nl_rev)
+ apply(rule_tac x = stp in exI, auto)
done
qed
- next
- show "wprepare_stop m args \<turnstile>-> wprepare_stop m args"
- by(simp add: t_imply_def)
+ qed
qed
- thus "\<exists> stp ln rn. steps (Suc 0, [], <m # args>) (t_wcode_prepare |+| t_wcode_main) stp
- = (0, Bk # Oc\<^bsup>Suc m\<^esup>, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<args>)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- apply(simp add: t_imply_def)
- apply(erule_tac exE)+
- apply(auto)
+ thus "?thesis"
+ apply(auto simp: Hoare_def)
+ apply(rule_tac x = n in exI)
+ apply(case_tac "(steps0 (Suc 0, [], <m # args>)
+ (turing_basic.adjust t_wcode_prepare @ shift t_wcode_main (length t_wcode_prepare div 2)) n)")
+ apply(auto simp: tm_comp.simps)
done
qed
-
-
+
lemma [simp]: "tinres r r' \<Longrightarrow>
- fetch t ss (case r of [] \<Rightarrow> Bk | x # xs \<Rightarrow> x) =
- fetch t ss (case r' of [] \<Rightarrow> Bk | x # xs \<Rightarrow> x)"
+ fetch t ss (read r) =
+ fetch t ss (read r')"
apply(simp add: fetch.simps, auto split: if_splits simp: tinres_def)
-apply(case_tac [!] r', simp_all)
-apply(case_tac [!] n, simp_all add: exp_ind_def)
-apply(case_tac [!] r, simp_all)
-done
-
-lemma [intro]: "\<exists> n. (a::block)\<^bsup>n\<^esup> = []"
+apply(case_tac [!] n, simp_all)
+done
+
+lemma [intro]: "\<exists> n. (a::cell)\<up>(n) = []"
by auto
lemma [simp]: "\<lbrakk>tinres r r'; r \<noteq> []; r' \<noteq> []\<rbrakk> \<Longrightarrow> hd r = hd r'"
apply(auto simp: tinres_def)
done
-lemma [intro]: "hd (Bk\<^bsup>Suc n\<^esup>) = Bk"
-apply(simp add: exp_ind_def)
+lemma [intro]: "hd (Bk\<up>(Suc n)) = Bk"
+apply(simp add: )
done
lemma [simp]: "\<lbrakk>tinres r []; r \<noteq> []\<rbrakk> \<Longrightarrow> hd r = Bk"
apply(auto simp: tinres_def)
-apply(case_tac n, auto)
done
lemma [simp]: "\<lbrakk>tinres [] r'; r' \<noteq> []\<rbrakk> \<Longrightarrow> hd r' = Bk"
apply(auto simp: tinres_def)
done
-lemma [intro]: "\<exists>na. tl r = tl (r @ Bk\<^bsup>n\<^esup>) @ Bk\<^bsup>na\<^esup> \<or> tl (r @ Bk\<^bsup>n\<^esup>) = tl r @ Bk\<^bsup>na\<^esup>"
+lemma [intro]: "\<exists>na. tl r = tl (r @ Bk\<up>(n)) @ Bk\<up>(na) \<or> tl (r @ Bk\<up>(n)) = tl r @ Bk\<up>(na)"
apply(case_tac r, simp)
-apply(case_tac n, simp)
-apply(rule_tac x = 0 in exI, simp)
-apply(rule_tac x = nat in exI, simp add: exp_ind_def)
-apply(simp)
+apply(case_tac n, simp, simp)
+apply(rule_tac x = nat in exI, simp)
apply(rule_tac x = n in exI, simp)
done
lemma [simp]: "tinres r r' \<Longrightarrow> tinres (tl r) (tl r')"
apply(auto simp: tinres_def)
-apply(case_tac r', simp_all)
-apply(case_tac n, simp_all add: exp_ind_def)
-apply(rule_tac x = 0 in exI, simp)
-apply(rule_tac x = nat in exI, simp_all)
+apply(case_tac r', simp)
+apply(case_tac n, simp_all)
+apply(rule_tac x = nat in exI, simp)
apply(rule_tac x = n in exI, simp)
done
lemma [simp]: "\<lbrakk>tinres r []; r \<noteq> []\<rbrakk> \<Longrightarrow> tinres (tl r) []"
apply(case_tac r, auto simp: tinres_def)
-apply(case_tac n, simp_all add: exp_ind_def)
+apply(case_tac n, simp_all add: )
apply(rule_tac x = nat in exI, simp)
done
lemma [simp]: "\<lbrakk>tinres [] r'\<rbrakk> \<Longrightarrow> tinres [] (tl r')"
apply(case_tac r', auto simp: tinres_def)
-apply(case_tac n, simp_all add: exp_ind_def)
+apply(case_tac n, simp_all add: )
apply(rule_tac x = nat in exI, simp)
done
@@ -3503,32 +3572,38 @@
apply(auto simp: tinres_def)
done
+lemma [simp]: "tinres r [] \<Longrightarrow> tinres (Bk # tl r) [Bk]"
+apply(auto simp: tinres_def)
+done
+
+lemma [simp]: "tinres r [] \<Longrightarrow> tinres (Oc # tl r) [Oc]"
+apply(auto simp: tinres_def)
+done
+
lemma tinres_step2:
- "\<lbrakk>tinres r r'; tstep (ss, l, r) t = (sa, la, ra); tstep (ss, l, r') t = (sb, lb, rb)\<rbrakk>
+ "\<lbrakk>tinres r r'; step0 (ss, l, r) t = (sa, la, ra); step0 (ss, l, r') t = (sb, lb, rb)\<rbrakk>
\<Longrightarrow> la = lb \<and> tinres ra rb \<and> sa = sb"
-apply(case_tac "ss = 0", simp add: tstep_0)
-apply(simp add: tstep.simps [simp del])
-apply(case_tac "fetch t ss (case r of [] \<Rightarrow> Bk | x # xs \<Rightarrow> x)", simp)
-apply(auto simp: new_tape.simps)
-apply(simp_all split: taction.splits if_splits)
-apply(auto)
-done
-
+apply(case_tac "ss = 0", simp add: step_0)
+apply(simp add: step.simps [simp del], auto)
+apply(case_tac [!] "fetch t ss (read r')", simp)
+apply(auto simp: update.simps)
+apply(case_tac [!] a, auto split: if_splits)
+done
lemma tinres_steps2:
- "\<lbrakk>tinres r r'; steps (ss, l, r) t stp = (sa, la, ra); steps (ss, l, r') t stp = (sb, lb, rb)\<rbrakk>
+ "\<lbrakk>tinres r r'; steps0 (ss, l, r) t stp = (sa, la, ra); steps0 (ss, l, r') t stp = (sb, lb, rb)\<rbrakk>
\<Longrightarrow> la = lb \<and> tinres ra rb \<and> sa = sb"
apply(induct stp arbitrary: sa la ra sb lb rb, simp add: steps.simps)
-apply(simp add: tstep_red)
-apply(case_tac "(steps (ss, l, r) t stp)")
-apply(case_tac "(steps (ss, l, r') t stp)")
+apply(simp add: step_red)
+apply(case_tac "(steps0 (ss, l, r) t stp)")
+apply(case_tac "(steps0 (ss, l, r') t stp)")
proof -
fix stp sa la ra sb lb rb a b c aa ba ca
- assume ind: "\<And>sa la ra sb lb rb. \<lbrakk>steps (ss, l, r) t stp = (sa, la, ra);
- steps (ss, l, r') t stp = (sb, lb, rb)\<rbrakk> \<Longrightarrow> la = lb \<and> tinres ra rb \<and> sa = sb"
- and h: " tinres r r'" "tstep (steps (ss, l, r) t stp) t = (sa, la, ra)"
- "tstep (steps (ss, l, r') t stp) t = (sb, lb, rb)" "steps (ss, l, r) t stp = (a, b, c)"
- "steps (ss, l, r') t stp = (aa, ba, ca)"
+ assume ind: "\<And>sa la ra sb lb rb. \<lbrakk>steps0 (ss, l, r) t stp = (sa, la, ra);
+ steps0 (ss, l, r') t stp = (sb, lb, rb)\<rbrakk> \<Longrightarrow> la = lb \<and> tinres ra rb \<and> sa = sb"
+ and h: " tinres r r'" "step0 (steps0 (ss, l, r) t stp) t = (sa, la, ra)"
+ "step0 (steps0 (ss, l, r') t stp) t = (sb, lb, rb)" "steps0 (ss, l, r) t stp = (a, b, c)"
+ "steps0 (ss, l, r') t stp = (aa, ba, ca)"
have "b = ba \<and> tinres c ca \<and> a = aa"
apply(rule_tac ind, simp_all add: h)
done
@@ -3539,8 +3614,8 @@
apply(simp, simp, simp)
done
qed
-
-definition t_wcode_adjust :: "tprog"
+
+definition t_wcode_adjust :: "instr list"
where
"t_wcode_adjust = [(W1, 1), (R, 2), (Nop, 2), (R, 3), (R, 3), (R, 4),
(L, 8), (L, 5), (L, 6), (W0, 5), (L, 6), (R, 7),
@@ -3566,112 +3641,115 @@
lemma [simp]: "fetch t_wcode_adjust (Suc (Suc (Suc 0))) Bk = (R, 3)"
apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
done
-
-lemma [simp]: "fetch t_wcode_adjust 4 Bk = (L, 8)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
-done
-
-lemma [simp]: "fetch t_wcode_adjust 4 Oc = (L, 5)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
-done
+
+lemma [simp]: "fetch t_wcode_adjust (Suc (Suc (Suc (Suc 0)))) Bk = (L, 8)"
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps numeral_4_eq_4)
+done
+
+lemma [simp]: "fetch t_wcode_adjust (Suc (Suc (Suc (Suc 0)))) Oc = (L, 5)"
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps numeral_4_eq_4)
+done
+
+thm numeral_5_eq_5
lemma [simp]: "fetch t_wcode_adjust 5 Oc = (W0, 5)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
+apply(simp only: fetch.simps t_wcode_adjust_def nth_of.simps numeral_5_eq_5, simp)
done
lemma [simp]: "fetch t_wcode_adjust 5 Bk = (L, 6)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
-done
-
+apply(simp only: fetch.simps t_wcode_adjust_def nth_of.simps numeral_5_eq_5, auto)
+done
+
+thm numeral_6_eq_6
lemma [simp]: "fetch t_wcode_adjust 6 Oc = (R, 7)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps numeral_6_eq_6)
done
lemma [simp]: "fetch t_wcode_adjust 6 Bk = (L, 6)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps numeral_6_eq_6)
done
lemma [simp]: "fetch t_wcode_adjust 7 Bk = (W1, 2)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps numeral_7_eq_7)
done
lemma [simp]: "fetch t_wcode_adjust 8 Bk = (L, 9)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps numeral_8_eq_8)
done
lemma [simp]: "fetch t_wcode_adjust 8 Oc = (W0, 8)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps numeral_8_eq_8)
done
lemma [simp]: "fetch t_wcode_adjust 9 Oc = (L, 10)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps numeral_9_eq_9)
done
lemma [simp]: "fetch t_wcode_adjust 9 Bk = (L, 9)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps numeral_9_eq_9)
done
lemma [simp]: "fetch t_wcode_adjust 10 Bk = (L, 11)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps numeral_10_eq_10)
done
lemma [simp]: "fetch t_wcode_adjust 10 Oc = (L, 10)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps eval_nat_numeral)
done
lemma [simp]: "fetch t_wcode_adjust 11 Oc = (L, 11)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps eval_nat_numeral)
done
lemma [simp]: "fetch t_wcode_adjust 11 Bk = (R, 0)"
-apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps)
+apply(simp add: fetch.simps t_wcode_adjust_def nth_of.simps eval_nat_numeral)
done
fun wadjust_start :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_start m rs (l, r) =
- (\<exists> ln rn. l = Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- tl r = Oc # Bk\<^bsup>ln\<^esup> @ Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ (\<exists> ln rn. l = Bk # Oc\<up>(Suc m) \<and>
+ tl r = Oc # Bk\<up>(ln) @ Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn))"
fun wadjust_loop_start :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_loop_start m rs (l, r) =
- (\<exists> ln rn ml mr. l = Oc\<^bsup>ml\<^esup> @ Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = Oc # Bk\<^bsup>ln\<^esup> @ Bk # Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ (\<exists> ln rn ml mr. l = Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
+ r = Oc # Bk\<up>(ln) @ Bk # Oc\<up>(mr) @ Bk\<up>(rn) \<and>
ml + mr = Suc (Suc rs) \<and> mr > 0)"
fun wadjust_loop_right_move :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_loop_right_move m rs (l, r) =
- (\<exists> ml mr nl nr rn. l = Bk\<^bsup>nl\<^esup> @ Oc # Oc\<^bsup>ml\<^esup> @ Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = Bk\<^bsup>nr\<^esup> @ Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ (\<exists> ml mr nl nr rn. l = Bk\<up>(nl) @ Oc # Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
+ r = Bk\<up>(nr) @ Oc\<up>(mr) @ Bk\<up>(rn) \<and>
ml + mr = Suc (Suc rs) \<and> mr > 0 \<and>
nl + nr > 0)"
fun wadjust_loop_check :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_loop_check m rs (l, r) =
- (\<exists> ml mr ln rn. l = Oc # Bk\<^bsup>ln\<^esup> @ Bk # Oc # Oc\<^bsup>ml\<^esup> @ Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<and> ml + mr = (Suc rs))"
+ (\<exists> ml mr ln rn. l = Oc # Bk\<up>(ln) @ Bk # Oc # Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
+ r = Oc\<up>(mr) @ Bk\<up>(rn) \<and> ml + mr = (Suc rs))"
fun wadjust_loop_erase :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_loop_erase m rs (l, r) =
- (\<exists> ml mr ln rn. l = Bk\<^bsup>ln\<^esup> @ Bk # Oc # Oc\<^bsup>ml\<^esup> @ Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- tl r = Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<and> ml + mr = (Suc rs) \<and> mr > 0)"
+ (\<exists> ml mr ln rn. l = Bk\<up>(ln) @ Bk # Oc # Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
+ tl r = Oc\<up>(mr) @ Bk\<up>(rn) \<and> ml + mr = (Suc rs) \<and> mr > 0)"
fun wadjust_loop_on_left_moving_O :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_loop_on_left_moving_O m rs (l, r) =
- (\<exists> ml mr ln rn. l = Oc\<^bsup>ml\<^esup> @ Bk # Oc\<^bsup>Suc m \<^esup>\<and>
- r = Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ (\<exists> ml mr ln rn. l = Oc\<up>(ml) @ Bk # Oc\<up>(Suc m )\<and>
+ r = Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(mr) @ Bk\<up>(rn) \<and>
ml + mr = Suc rs \<and> mr > 0)"
fun wadjust_loop_on_left_moving_B :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_loop_on_left_moving_B m rs (l, r) =
- (\<exists> ml mr nl nr rn. l = Bk\<^bsup>nl\<^esup> @ Oc # Oc\<^bsup>ml\<^esup> @ Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = Bk\<^bsup>nr\<^esup> @ Bk # Bk # Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ (\<exists> ml mr nl nr rn. l = Bk\<up>(nl) @ Oc # Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
+ r = Bk\<up>(nr) @ Bk # Bk # Oc\<up>(mr) @ Bk\<up>(rn) \<and>
ml + mr = Suc rs \<and> mr > 0)"
fun wadjust_loop_on_left_moving :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
@@ -3683,27 +3761,27 @@
fun wadjust_loop_right_move2 :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_loop_right_move2 m rs (l, r) =
- (\<exists> ml mr ln rn. l = Oc # Oc\<^bsup>ml\<^esup> @ Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ (\<exists> ml mr ln rn. l = Oc # Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
+ r = Bk\<up>(ln) @ Bk # Bk # Oc\<up>(mr) @ Bk\<up>(rn) \<and>
ml + mr = Suc rs \<and> mr > 0)"
fun wadjust_erase2 :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_erase2 m rs (l, r) =
- (\<exists> ln rn. l = Bk\<^bsup>ln\<^esup> @ Bk # Oc # Oc\<^bsup>Suc rs\<^esup> @ Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- tl r = Bk\<^bsup>rn\<^esup>)"
+ (\<exists> ln rn. l = Bk\<up>(ln) @ Bk # Oc # Oc\<up>(Suc rs) @ Bk # Oc\<up>(Suc m) \<and>
+ tl r = Bk\<up>(rn))"
fun wadjust_on_left_moving_O :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_on_left_moving_O m rs (l, r) =
- (\<exists> rn. l = Oc\<^bsup>Suc rs\<^esup> @ Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = Oc # Bk\<^bsup>rn\<^esup>)"
+ (\<exists> rn. l = Oc\<up>(Suc rs) @ Bk # Oc\<up>(Suc m) \<and>
+ r = Oc # Bk\<up>(rn))"
fun wadjust_on_left_moving_B :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_on_left_moving_B m rs (l, r) =
- (\<exists> ln rn. l = Bk\<^bsup>ln\<^esup> @ Oc # Oc\<^bsup>Suc rs\<^esup> @ Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = Bk\<^bsup>rn\<^esup>)"
+ (\<exists> ln rn. l = Bk\<up>(ln) @ Oc # Oc\<up>(Suc rs) @ Bk # Oc\<up>(Suc m) \<and>
+ r = Bk\<up>(rn))"
fun wadjust_on_left_moving :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
@@ -3714,14 +3792,14 @@
fun wadjust_goon_left_moving_B :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_goon_left_moving_B m rs (l, r) =
- (\<exists> rn. l = Oc\<^bsup>Suc m\<^esup> \<and>
- r = Bk # Oc\<^bsup>Suc (Suc rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ (\<exists> rn. l = Oc\<up>(Suc m) \<and>
+ r = Bk # Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
fun wadjust_goon_left_moving_O :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_goon_left_moving_O m rs (l, r) =
- (\<exists> ml mr rn. l = Oc\<^bsup>ml\<^esup> @ Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- r = Oc\<^bsup>mr\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ (\<exists> ml mr rn. l = Oc\<up>(ml) @ Bk # Oc\<up>(Suc m) \<and>
+ r = Oc\<up>(mr) @ Bk\<up>(rn) \<and>
ml + mr = Suc (Suc rs) \<and> mr > 0)"
fun wadjust_goon_left_moving :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
@@ -3734,13 +3812,13 @@
where
"wadjust_backto_standard_pos_B m rs (l, r) =
(\<exists> rn. l = [] \<and>
- r = Bk # Oc\<^bsup>Suc m \<^esup>@ Bk # Oc\<^bsup>Suc (Suc rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ r = Bk # Oc\<up>(Suc m )@ Bk # Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
fun wadjust_backto_standard_pos_O :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
where
"wadjust_backto_standard_pos_O m rs (l, r) =
- (\<exists> ml mr rn. l = Oc\<^bsup>ml\<^esup> \<and>
- r = Oc\<^bsup>mr\<^esup> @ Bk # Oc\<^bsup>Suc (Suc rs)\<^esup> @ Bk\<^bsup>rn\<^esup> \<and>
+ (\<exists> ml mr rn. l = Oc\<up>(ml) \<and>
+ r = Oc\<up>(mr) @ Bk # Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn) \<and>
ml + mr = Suc m \<and> mr > 0)"
fun wadjust_backto_standard_pos :: "nat \<Rightarrow> nat \<Rightarrow> tape \<Rightarrow> bool"
@@ -3753,7 +3831,7 @@
where
"wadjust_stop m rs (l, r) =
(\<exists> rn. l = [Bk] \<and>
- r = Oc\<^bsup>Suc m \<^esup>@ Bk # Oc\<^bsup>Suc (Suc rs)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ r = Oc\<up>(Suc m )@ Bk # Oc\<up>(Suc (Suc rs)) @ Bk\<up>(rn))"
declare wadjust_start.simps[simp del] wadjust_loop_start.simps[simp del]
wadjust_loop_right_move.simps[simp del] wadjust_loop_check.simps[simp del]
@@ -3785,7 +3863,7 @@
declare wadjust_inv.simps[simp del]
-fun wadjust_phase :: "nat \<Rightarrow> t_conf \<Rightarrow> nat"
+fun wadjust_phase :: "nat \<Rightarrow> config \<Rightarrow> nat"
where
"wadjust_phase rs (st, l, r) =
(if st = 1 then 3
@@ -3793,9 +3871,7 @@
else if st \<ge> 8 \<and> st \<le> 11 then 1
else 0)"
-thm dropWhile.simps
-
-fun wadjust_stage :: "nat \<Rightarrow> t_conf \<Rightarrow> nat"
+fun wadjust_stage :: "nat \<Rightarrow> config \<Rightarrow> nat"
where
"wadjust_stage rs (st, l, r) =
(if st \<ge> 2 \<and> st \<le> 7 then
@@ -3803,14 +3879,14 @@
(tl (dropWhile (\<lambda> a. a = Oc) (rev l @ r))))
else 0)"
-fun wadjust_state :: "nat \<Rightarrow> t_conf \<Rightarrow> nat"
+fun wadjust_state :: "nat \<Rightarrow> config \<Rightarrow> nat"
where
"wadjust_state rs (st, l, r) =
(if st \<ge> 2 \<and> st \<le> 7 then 8 - st
else if st \<ge> 8 \<and> st \<le> 11 then 12 - st
else 0)"
-fun wadjust_step :: "nat \<Rightarrow> t_conf \<Rightarrow> nat"
+fun wadjust_step :: "nat \<Rightarrow> config \<Rightarrow> nat"
where
"wadjust_step rs (st, l, r) =
(if st = 1 then (if hd r = Bk then 1
@@ -3827,7 +3903,7 @@
else Suc (length l))
else 0)"
-fun wadjust_measure :: "(nat \<times> t_conf) \<Rightarrow> nat \<times> nat \<times> nat \<times> nat"
+fun wadjust_measure :: "(nat \<times> config) \<Rightarrow> nat \<times> nat \<times> nat \<times> nat"
where
"wadjust_measure (rs, (st, l, r)) =
(wadjust_phase rs (st, l, r),
@@ -3835,7 +3911,7 @@
wadjust_state rs (st, l, r),
wadjust_step rs (st, l, r))"
-definition wadjust_le :: "((nat \<times> t_conf) \<times> nat \<times> t_conf) set"
+definition wadjust_le :: "((nat \<times> config) \<times> nat \<times> config) set"
where "wadjust_le \<equiv> (inv_image lex_square wadjust_measure)"
lemma [intro]: "wf lex_square"
@@ -3858,7 +3934,6 @@
\<Longrightarrow> wadjust_loop_check m rs (Bk # c, [])"
apply(simp only: wadjust_loop_right_move.simps wadjust_loop_check.simps)
apply(auto)
-apply(case_tac [!] mr, simp_all add: exp_ind_def)
done
lemma [simp]: "wadjust_loop_check m rs (c, []) \<Longrightarrow> c \<noteq> []"
@@ -3874,19 +3949,16 @@
apply(simp only: wadjust_loop_right_move.simps)
apply(erule_tac exE)+
apply(auto)
-apply(case_tac [!] mr, simp_all add: exp_ind_def)
done
lemma [simp]: "wadjust_loop_check m rs (c, []) \<Longrightarrow> wadjust_erase2 m rs (tl c, [hd c])"
apply(simp only: wadjust_loop_check.simps wadjust_erase2.simps, auto)
-apply(case_tac mr, simp_all add: exp_ind_def, auto)
done
lemma [simp]: " wadjust_loop_erase m rs (c, [])
\<Longrightarrow> (c = [] \<longrightarrow> wadjust_loop_on_left_moving m rs ([], [Bk])) \<and>
(c \<noteq> [] \<longrightarrow> wadjust_loop_on_left_moving m rs (tl c, [hd c]))"
-apply(simp add: wadjust_loop_erase.simps, auto)
-apply(case_tac [!] mr, simp_all add: exp_ind_def)
+apply(simp add: wadjust_loop_erase.simps)
done
lemma [simp]: "wadjust_loop_on_left_moving m rs (c, []) = False"
@@ -3903,22 +3975,21 @@
done
lemma [simp]: "wadjust_on_left_moving_B m rs
- (Oc # Oc # Oc\<^bsup>rs\<^esup> @ Bk # Oc # Oc\<^bsup>m\<^esup>, [Bk])"
+ (Oc # Oc # Oc\<up>(rs) @ Bk # Oc # Oc\<up>(m), [Bk])"
apply(simp add: wadjust_on_left_moving_B.simps, auto)
-apply(rule_tac x = 0 in exI, simp add: exp_ind_def)
done
lemma [simp]: "wadjust_on_left_moving_B m rs
- (Bk\<^bsup>n\<^esup> @ Bk # Oc # Oc # Oc\<^bsup>rs\<^esup> @ Bk # Oc # Oc\<^bsup>m\<^esup>, [Bk])"
-apply(simp add: wadjust_on_left_moving_B.simps exp_ind_def, auto)
-apply(rule_tac x = "Suc n" in exI, simp add: exp_ind)
+ (Bk\<up>(n) @ Bk # Oc # Oc # Oc\<up>(rs) @ Bk # Oc # Oc\<up>(m), [Bk])"
+apply(simp add: wadjust_on_left_moving_B.simps , auto)
+apply(rule_tac x = "Suc n" in exI, simp add: exp_ind del: replicate_Suc)
done
lemma [simp]: "\<lbrakk>wadjust_erase2 m rs (c, []); c \<noteq> []\<rbrakk> \<Longrightarrow>
wadjust_on_left_moving m rs (tl c, [hd c])"
apply(simp only: wadjust_erase2.simps)
apply(erule_tac exE)+
-apply(case_tac ln, simp_all add: exp_ind_def wadjust_on_left_moving.simps)
+apply(case_tac ln, simp_all add: wadjust_on_left_moving.simps)
done
lemma [simp]: "wadjust_erase2 m rs (c, [])
@@ -3939,13 +4010,13 @@
lemma [simp]: " \<lbrakk>wadjust_on_left_moving_B m rs (c, []); c \<noteq> []; hd c = Bk\<rbrakk> \<Longrightarrow>
wadjust_on_left_moving_B m rs (tl c, [Bk])"
apply(simp add: wadjust_on_left_moving_B.simps, auto)
-apply(case_tac [!] ln, simp_all add: exp_ind_def, auto)
+apply(case_tac [!] ln, simp_all)
done
lemma [simp]: "\<lbrakk>wadjust_on_left_moving_B m rs (c, []); c \<noteq> []; hd c = Oc\<rbrakk> \<Longrightarrow>
wadjust_on_left_moving_O m rs (tl c, [Oc])"
apply(simp add: wadjust_on_left_moving_B.simps wadjust_on_left_moving_O.simps, auto)
-apply(case_tac [!] ln, simp_all add: exp_ind_def)
+apply(case_tac [!] ln, simp_all add: )
done
lemma [simp]: "\<lbrakk>wadjust_on_left_moving m rs (c, []); c \<noteq> []\<rbrakk> \<Longrightarrow>
@@ -3991,8 +4062,8 @@
apply(erule_tac exE)+
apply(rule_tac x = ml in exI, simp)
apply(rule_tac x = mr in exI, simp)
-apply(rule_tac x = "Suc nl" in exI, simp add: exp_ind_def)
-apply(case_tac nr, simp, case_tac mr, simp_all add: exp_ind_def)
+apply(rule_tac x = "Suc nl" in exI, simp add: )
+apply(case_tac nr, simp, case_tac mr, simp_all add: )
apply(rule_tac x = nat in exI, auto)
done
@@ -4003,7 +4074,7 @@
lemma [simp]: "wadjust_loop_check m rs (c, Bk # list)
\<Longrightarrow> wadjust_erase2 m rs (tl c, hd c # Bk # list)"
apply(auto simp: wadjust_loop_check.simps wadjust_erase2.simps)
-apply(case_tac [!] mr, simp_all add: exp_ind_def, auto)
+apply(case_tac [!] mr, simp_all)
done
lemma [simp]: "wadjust_loop_erase m rs (c, b) \<Longrightarrow> c \<noteq> []"
@@ -4020,15 +4091,15 @@
apply(erule_tac exE)+
apply(rule_tac x = ml in exI, rule_tac x = mr in exI,
rule_tac x = ln in exI, rule_tac x = 0 in exI, simp)
-apply(case_tac ln, simp_all add: exp_ind_def, auto)
-apply(simp add: exp_ind exp_ind_def[THEN sym])
+apply(case_tac ln, simp_all add: , auto)
+apply(simp add: exp_ind [THEN sym])
done
lemma [simp]: "\<lbrakk>wadjust_loop_erase m rs (c, Bk # list); c \<noteq> []; hd c = Oc\<rbrakk> \<Longrightarrow>
wadjust_loop_on_left_moving_O m rs (tl c, Oc # Bk # list)"
apply(simp only: wadjust_loop_erase.simps wadjust_loop_on_left_moving_O.simps,
auto)
-apply(case_tac [!] ln, simp_all add: exp_ind_def)
+apply(case_tac [!] ln, simp_all add: )
done
lemma [simp]: "\<lbrakk>wadjust_loop_erase m rs (c, Bk # list); c \<noteq> []\<rbrakk> \<Longrightarrow>
@@ -4050,8 +4121,8 @@
apply(simp only: wadjust_loop_on_left_moving_B.simps)
apply(erule_tac exE)+
apply(rule_tac x = ml in exI, rule_tac x = mr in exI)
-apply(case_tac nl, simp_all add: exp_ind_def, auto)
-apply(rule_tac x = "Suc nr" in exI, auto simp: exp_ind_def)
+apply(case_tac nl, simp_all add: , auto)
+apply(rule_tac x = "Suc nr" in exI, auto simp: )
done
lemma [simp]: "\<lbrakk>wadjust_loop_on_left_moving_B m rs (c, Bk # list); hd c = Oc\<rbrakk>
@@ -4060,7 +4131,7 @@
wadjust_loop_on_left_moving_B.simps)
apply(erule_tac exE)+
apply(rule_tac x = ml in exI, rule_tac x = mr in exI)
-apply(case_tac nl, simp_all add: exp_ind_def, auto)
+apply(case_tac nl, simp_all add: , auto)
done
lemma [simp]: "wadjust_loop_on_left_moving m rs (c, Bk # list)
@@ -4075,13 +4146,13 @@
lemma [simp]: "wadjust_loop_right_move2 m rs (c, Bk # list) \<Longrightarrow> wadjust_loop_start m rs (c, Oc # list)"
apply(auto simp: wadjust_loop_right_move2.simps wadjust_loop_start.simps)
-apply(case_tac ln, simp_all add: exp_ind_def)
+apply(case_tac ln, simp_all add: )
apply(rule_tac x = 0 in exI, simp)
apply(rule_tac x = rn in exI, simp)
-apply(rule_tac x = "Suc ml" in exI, simp add: exp_ind_def, auto)
-apply(rule_tac x = "Suc nat" in exI, simp add: exp_ind)
+apply(rule_tac x = "Suc ml" in exI, simp add: , auto)
+apply(rule_tac x = "Suc nat" in exI, simp add: exp_ind del: replicate_Suc)
apply(rule_tac x = rn in exI, auto)
-apply(rule_tac x = "Suc ml" in exI, auto simp: exp_ind_def)
+apply(rule_tac x = "Suc ml" in exI, auto )
done
lemma [simp]: "wadjust_erase2 m rs (c, Bk # list) \<Longrightarrow> c \<noteq> []"
@@ -4091,12 +4162,12 @@
lemma [simp]: "wadjust_erase2 m rs (c, Bk # list) \<Longrightarrow>
wadjust_on_left_moving m rs (tl c, hd c # Bk # list)"
apply(auto simp: wadjust_erase2.simps)
-apply(case_tac ln, simp_all add: exp_ind_def wadjust_on_left_moving.simps
+apply(case_tac ln, simp_all add: wadjust_on_left_moving.simps
wadjust_on_left_moving_O.simps wadjust_on_left_moving_B.simps)
apply(auto)
-apply(rule_tac x = "(Suc (Suc rn))" in exI, simp add: exp_ind_def)
-apply(rule_tac x = "Suc nat" in exI, simp add: exp_ind)
-apply(rule_tac x = "(Suc (Suc rn))" in exI, simp add: exp_ind_def)
+apply(rule_tac x = "(Suc (Suc rn))" in exI, simp add: )
+apply(rule_tac x = "Suc nat" in exI, simp add: exp_ind del: replicate_Suc)
+apply(rule_tac x = "(Suc (Suc rn))" in exI, simp add: )
done
lemma [simp]: "wadjust_on_left_moving m rs (c,b) \<Longrightarrow> c \<noteq> []"
@@ -4113,14 +4184,14 @@
lemma [simp]: "\<lbrakk>wadjust_on_left_moving_B m rs (c, Bk # list); hd c = Bk\<rbrakk>
\<Longrightarrow> wadjust_on_left_moving_B m rs (tl c, Bk # Bk # list)"
apply(auto simp: wadjust_on_left_moving_B.simps)
-apply(case_tac ln, simp_all add: exp_ind_def, auto)
+apply(case_tac ln, simp_all)
done
lemma [simp]: "\<lbrakk>wadjust_on_left_moving_B m rs (c, Bk # list); hd c = Oc\<rbrakk>
\<Longrightarrow> wadjust_on_left_moving_O m rs (tl c, Oc # Bk # list)"
apply(auto simp: wadjust_on_left_moving_O.simps
wadjust_on_left_moving_B.simps)
-apply(case_tac ln, simp_all add: exp_ind_def)
+apply(case_tac ln, simp_all add: )
done
lemma [simp]: "wadjust_on_left_moving m rs (c, Bk # list) \<Longrightarrow>
@@ -4132,25 +4203,24 @@
lemma [simp]: "wadjust_goon_left_moving m rs (c, b) \<Longrightarrow> c \<noteq> []"
apply(simp add: wadjust_goon_left_moving.simps
wadjust_goon_left_moving_B.simps
- wadjust_goon_left_moving_O.simps exp_ind_def, auto)
+ wadjust_goon_left_moving_O.simps , auto)
done
lemma [simp]: "wadjust_goon_left_moving_O m rs (c, Bk # list) = False"
apply(simp add: wadjust_goon_left_moving_O.simps, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
+apply(case_tac mr, simp_all add: )
done
lemma [simp]: "\<lbrakk>wadjust_goon_left_moving_B m rs (c, Bk # list); hd c = Bk\<rbrakk>
\<Longrightarrow> wadjust_backto_standard_pos_B m rs (tl c, Bk # Bk # list)"
apply(auto simp: wadjust_goon_left_moving_B.simps
- wadjust_backto_standard_pos_B.simps exp_ind_def)
+ wadjust_backto_standard_pos_B.simps )
done
lemma [simp]: "\<lbrakk>wadjust_goon_left_moving_B m rs (c, Bk # list); hd c = Oc\<rbrakk>
\<Longrightarrow> wadjust_backto_standard_pos_O m rs (tl c, Oc # Bk # list)"
apply(auto simp: wadjust_goon_left_moving_B.simps
- wadjust_backto_standard_pos_O.simps exp_ind_def)
-apply(rule_tac x = m in exI, simp, auto)
+ wadjust_backto_standard_pos_O.simps)
done
lemma [simp]: "wadjust_goon_left_moving m rs (c, Bk # list) \<Longrightarrow>
@@ -4164,7 +4234,7 @@
apply(auto simp: wadjust_backto_standard_pos.simps
wadjust_backto_standard_pos_B.simps
wadjust_backto_standard_pos_O.simps wadjust_stop.simps)
-apply(case_tac [!] mr, simp_all add: exp_ind_def)
+apply(case_tac [!] mr, simp_all add: )
done
lemma [simp]: "wadjust_start m rs (c, Oc # list)
@@ -4184,17 +4254,17 @@
apply(simp add: wadjust_loop_start.simps wadjust_loop_right_move.simps, auto)
apply(rule_tac x = ml in exI, rule_tac x = mr in exI,
rule_tac x = 0 in exI, simp)
-apply(rule_tac x = "Suc ln" in exI, simp add: exp_ind, auto)
+apply(rule_tac x = "Suc ln" in exI, simp add: exp_ind del: replicate_Suc)
done
lemma [simp]: "wadjust_loop_right_move m rs (c, Oc # list) \<Longrightarrow>
wadjust_loop_check m rs (Oc # c, list)"
apply(simp add: wadjust_loop_right_move.simps
wadjust_loop_check.simps, auto)
-apply(rule_tac [!] x = ml in exI, simp_all, auto)
-apply(case_tac nl, auto simp: exp_ind_def)
-apply(rule_tac x = "mr - 1" in exI, case_tac mr, simp_all add: exp_ind_def)
-apply(case_tac [!] nr, simp_all add: exp_ind_def, auto)
+apply(rule_tac [!] x = ml in exI, simp_all add: exp_ind del: replicate_Suc, auto)
+apply(case_tac nl, simp_all add: exp_ind del: replicate_Suc)
+apply(rule_tac x = "mr - 1" in exI, case_tac mr, simp_all add: )
+apply(case_tac [!] nr, simp_all)
done
lemma [simp]: "wadjust_loop_check m rs (c, Oc # list) \<Longrightarrow>
@@ -4202,8 +4272,7 @@
apply(simp only: wadjust_loop_check.simps wadjust_loop_erase.simps)
apply(erule_tac exE)+
apply(rule_tac x = ml in exI, rule_tac x = mr in exI, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
-apply(case_tac rn, simp_all add: exp_ind_def)
+apply(case_tac mr, simp_all add: )
done
lemma [simp]: "wadjust_loop_erase m rs (c, Oc # list) \<Longrightarrow>
@@ -4213,7 +4282,7 @@
lemma [simp]: "wadjust_loop_on_left_moving_B m rs (c, Oc # list) = False"
apply(auto simp: wadjust_loop_on_left_moving_B.simps)
-apply(case_tac nr, simp_all add: exp_ind_def)
+apply(case_tac nr, simp_all add: )
done
lemma [simp]: "wadjust_loop_on_left_moving m rs (c, Oc # list)
@@ -4225,7 +4294,7 @@
lemma [simp]: "wadjust_loop_right_move2 m rs (c, Oc # list) = False"
apply(auto simp: wadjust_loop_right_move2.simps )
-apply(case_tac ln, simp_all add: exp_ind_def)
+apply(case_tac ln, simp_all add: )
done
lemma [simp]: "wadjust_erase2 m rs (c, Oc # list)
@@ -4241,15 +4310,14 @@
lemma [simp]: "\<lbrakk>wadjust_on_left_moving_O m rs (c, Oc # list); hd c = Bk\<rbrakk> \<Longrightarrow>
wadjust_goon_left_moving_B m rs (tl c, Bk # Oc # list)"
apply(auto simp: wadjust_on_left_moving_O.simps
- wadjust_goon_left_moving_B.simps exp_ind_def)
+ wadjust_goon_left_moving_B.simps )
done
lemma [simp]: "\<lbrakk>wadjust_on_left_moving_O m rs (c, Oc # list); hd c = Oc\<rbrakk>
\<Longrightarrow> wadjust_goon_left_moving_O m rs (tl c, Oc # Oc # list)"
apply(auto simp: wadjust_on_left_moving_O.simps
- wadjust_goon_left_moving_O.simps exp_ind_def)
-apply(rule_tac x = rs in exI, simp)
-apply(auto simp: exp_ind_def numeral_2_eq_2)
+ wadjust_goon_left_moving_O.simps )
+apply(auto simp: numeral_2_eq_2)
done
@@ -4274,15 +4342,15 @@
lemma [simp]: "\<lbrakk>wadjust_goon_left_moving_O m rs (c, Oc # list); hd c = Bk\<rbrakk>
\<Longrightarrow> wadjust_goon_left_moving_B m rs (tl c, Bk # Oc # list)"
apply(auto simp: wadjust_goon_left_moving_O.simps wadjust_goon_left_moving_B.simps)
-apply(case_tac [!] ml, auto simp: exp_ind_def)
+apply(case_tac [!] ml, auto simp: )
done
lemma [simp]: "\<lbrakk>wadjust_goon_left_moving_O m rs (c, Oc # list); hd c = Oc\<rbrakk> \<Longrightarrow>
wadjust_goon_left_moving_O m rs (tl c, Oc # Oc # list)"
apply(auto simp: wadjust_goon_left_moving_O.simps wadjust_goon_left_moving_B.simps)
apply(rule_tac x = "ml - 1" in exI, simp)
-apply(case_tac ml, simp_all add: exp_ind_def)
-apply(rule_tac x = "Suc mr" in exI, auto simp: exp_ind_def)
+apply(case_tac ml, simp_all add: )
+apply(rule_tac x = "Suc mr" in exI, auto simp: )
done
lemma [simp]: "wadjust_goon_left_moving m rs (c, Oc # list) \<Longrightarrow>
@@ -4297,33 +4365,26 @@
lemma [simp]: "wadjust_backto_standard_pos_O m rs (c, Bk # xs) = False"
apply(simp add: wadjust_backto_standard_pos_O.simps, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
-done
-
-
+apply(case_tac mr, simp_all add: )
+done
lemma [simp]: "wadjust_backto_standard_pos_O m rs ([], Oc # list) \<Longrightarrow>
wadjust_backto_standard_pos_B m rs ([], Bk # Oc # list)"
apply(auto simp: wadjust_backto_standard_pos_O.simps
wadjust_backto_standard_pos_B.simps)
-apply(rule_tac x = rn in exI, simp)
-apply(case_tac ml, simp_all add: exp_ind_def)
-done
-
+done
lemma [simp]:
"\<lbrakk>wadjust_backto_standard_pos_O m rs (c, Oc # list); c \<noteq> []; hd c = Bk\<rbrakk>
\<Longrightarrow> wadjust_backto_standard_pos_B m rs (tl c, Bk # Oc # list)"
apply(simp add:wadjust_backto_standard_pos_O.simps
wadjust_backto_standard_pos_B.simps, auto)
-apply(case_tac [!] ml, simp_all add: exp_ind_def)
done
lemma [simp]: "\<lbrakk>wadjust_backto_standard_pos_O m rs (c, Oc # list); c \<noteq> []; hd c = Oc\<rbrakk>
\<Longrightarrow> wadjust_backto_standard_pos_O m rs (tl c, Oc # Oc # list)"
apply(simp add: wadjust_backto_standard_pos_O.simps, auto)
-apply(case_tac ml, simp_all add: exp_ind_def, auto)
-apply(rule_tac x = nat in exI, auto simp: exp_ind_def)
+apply(case_tac ml, simp_all add: , auto)
done
lemma [simp]: "wadjust_backto_standard_pos m rs (c, Oc # list)
@@ -4332,19 +4393,17 @@
apply(auto simp: wadjust_backto_standard_pos.simps)
apply(case_tac "hd c", simp_all)
done
-thm wadjust_loop_right_move.simps
lemma [simp]: "wadjust_loop_right_move m rs (c, []) = False"
apply(simp only: wadjust_loop_right_move.simps)
apply(rule_tac iffI)
apply(erule_tac exE)+
-apply(case_tac nr, simp_all add: exp_ind_def)
-apply(case_tac mr, simp_all add: exp_ind_def)
+apply(case_tac nr, simp_all add: )
+apply(case_tac mr, simp_all add: )
done
lemma [simp]: "wadjust_loop_erase m rs (c, []) = False"
apply(simp only: wadjust_loop_erase.simps, auto)
-apply(case_tac mr, simp_all add: exp_ind_def)
done
lemma [simp]: "\<lbrakk>Suc (Suc rs) = a; wadjust_loop_erase m rs (c, Bk # list)\<rbrakk>
@@ -4367,11 +4426,11 @@
apply(case_tac c, simp_all)
done
-lemma dropWhile_exp1: "dropWhile (\<lambda>a. a = Oc) (Oc\<^bsup>n\<^esup> @ xs) = dropWhile (\<lambda>a. a = Oc) xs"
-apply(induct n, simp_all add: exp_ind_def)
-done
-lemma takeWhile_exp1: "takeWhile (\<lambda>a. a = Oc) (Oc\<^bsup>n\<^esup> @ xs) = Oc\<^bsup>n\<^esup> @ takeWhile (\<lambda>a. a = Oc) xs"
-apply(induct n, simp_all add: exp_ind_def)
+lemma dropWhile_exp1: "dropWhile (\<lambda>a. a = Oc) (Oc\<up>(n) @ xs) = dropWhile (\<lambda>a. a = Oc) xs"
+apply(induct n, simp_all add: )
+done
+lemma takeWhile_exp1: "takeWhile (\<lambda>a. a = Oc) (Oc\<up>(n) @ xs) = Oc\<up>(n) @ takeWhile (\<lambda>a. a = Oc) xs"
+apply(induct n, simp_all add: )
done
lemma [simp]: "\<lbrakk>Suc (Suc rs) = a; wadjust_loop_right_move2 m rs (c, Bk # list)\<rbrakk>
@@ -4379,7 +4438,7 @@
< a - length (takeWhile (\<lambda>a. a = Oc) (tl (dropWhile (\<lambda>a. a = Oc) (rev c @ Bk # list))))"
apply(simp add: wadjust_loop_right_move2.simps, auto)
apply(simp add: dropWhile_exp1 takeWhile_exp1)
-apply(case_tac ln, simp, simp add: exp_ind_def)
+apply(case_tac ln, simp, simp add: )
done
lemma [simp]: "wadjust_loop_check m rs ([], b) = False"
@@ -4411,129 +4470,119 @@
lemma wadjust_correctness:
shows "let P = (\<lambda> (len, st, l, r). st = 0) in
let Q = (\<lambda> (len, st, l, r). wadjust_inv st m rs (l, r)) in
- let f = (\<lambda> stp. (Suc (Suc rs), steps (Suc 0, Bk # Oc\<^bsup>Suc m\<^esup>,
- Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>) t_wcode_adjust stp)) in
+ let f = (\<lambda> stp. (Suc (Suc rs), steps0 (Suc 0, Bk # Oc\<up>(Suc m),
+ Bk # Oc # Bk\<up>(ln) @ Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn)) t_wcode_adjust stp)) in
\<exists> n .P (f n) \<and> Q (f n)"
proof -
let ?P = "(\<lambda> (len, st, l, r). st = 0)"
let ?Q = "\<lambda> (len, st, l, r). wadjust_inv st m rs (l, r)"
- let ?f = "\<lambda> stp. (Suc (Suc rs), steps (Suc 0, Bk # Oc\<^bsup>Suc m\<^esup>,
- Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>) t_wcode_adjust stp)"
+ let ?f = "\<lambda> stp. (Suc (Suc rs), steps0 (Suc 0, Bk # Oc\<up>(Suc m),
+ Bk # Oc # Bk\<up>(ln) @ Bk # Oc\<up>(Suc rs) @ Bk\<up>(rn)) t_wcode_adjust stp)"
have "\<exists> n. ?P (?f n) \<and> ?Q (?f n)"
proof(rule_tac halt_lemma2)
show "wf wadjust_le" by auto
next
show "\<forall> n. \<not> ?P (?f n) \<and> ?Q (?f n) \<longrightarrow>
?Q (?f (Suc n)) \<and> (?f (Suc n), ?f n) \<in> wadjust_le"
- proof(rule_tac allI, rule_tac impI, case_tac "?f n",
- simp add: tstep_red tstep.simps, rule_tac conjI, erule_tac conjE,
- erule_tac conjE)
- fix n a b c d
- assume "0 < b" "wadjust_inv b m rs (c, d)" "Suc (Suc rs) = a"
- thus "case case fetch t_wcode_adjust b (case d of [] \<Rightarrow> Bk | x # xs \<Rightarrow> x)
- of (ac, ns) \<Rightarrow> (ns, new_tape ac (c, d)) of (st, x) \<Rightarrow> wadjust_inv st m rs x"
- apply(case_tac d, simp, case_tac [2] aa)
- apply(simp_all add: wadjust_inv.simps wadjust_le_def new_tape.simps
- abacus.lex_triple_def abacus.lex_pair_def lex_square_def
- split: if_splits)
- done
- next
- fix n a b c d
- assume "0 < b \<and> wadjust_inv b m rs (c, d)"
- "Suc (Suc rs) = a \<and> steps (Suc 0, Bk # Oc\<^bsup>Suc m\<^esup>,
- Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>rn\<^esup>) t_wcode_adjust n = (b, c, d)"
- thus "((a, case fetch t_wcode_adjust b (case d of [] \<Rightarrow> Bk | x # xs \<Rightarrow> x)
- of (ac, ns) \<Rightarrow> (ns, new_tape ac (c, d))), a, b, c, d) \<in> wadjust_le"
- proof(erule_tac conjE, erule_tac conjE, erule_tac conjE)
- assume "0 < b" "wadjust_inv b m rs (c, d)" "Suc (Suc rs) = a"
- thus "?thesis"
- apply(case_tac d, case_tac [2] aa)
- apply(simp_all add: wadjust_inv.simps wadjust_le_def new_tape.simps
- abacus.lex_triple_def abacus.lex_pair_def lex_square_def
+ apply(rule_tac allI, rule_tac impI, case_tac "?f n", simp)
+ apply(simp add: step.simps)
+ apply(case_tac d, case_tac [2] aa, simp_all)
+ apply(simp_all add: wadjust_inv.simps wadjust_le_def
+ abacus.lex_triple_def abacus.lex_pair_def lex_square_def numeral_4_eq_4
split: if_splits)
- done
- qed
- qed
+ done
next
show "?Q (?f 0)"
- apply(simp add: steps.simps wadjust_inv.simps wadjust_start.simps)
- apply(rule_tac x = ln in exI,auto)
+ apply(simp add: steps.simps wadjust_inv.simps wadjust_start.simps, auto)
done
next
show "\<not> ?P (?f 0)"
apply(simp add: steps.simps)
done
qed
- thus "?thesis"
- apply(auto)
+ thus"?thesis"
+ apply(simp)
done
qed
-lemma [intro]: "t_correct t_wcode_adjust"
-apply(auto simp: t_wcode_adjust_def t_correct.simps iseven_def)
-apply(rule_tac x = 11 in exI, simp)
+lemma [intro]: "tm_wf (t_wcode_adjust, 0)"
+apply(auto simp: t_wcode_adjust_def tm_wf.simps)
+done
+
+declare tm_comp.simps[simp del]
+
+lemma [simp]: "args \<noteq> [] \<Longrightarrow> bl_bin (<args::nat list>) > 0"
+apply(case_tac args)
+apply(auto simp: tape_of_nl_cons bl_bin.simps split: if_splits)
done
lemma wcode_lemma_pre':
"args \<noteq> [] \<Longrightarrow>
- \<exists> stp rn. steps (Suc 0, [], <m # args>)
+ \<exists> stp rn. steps0 (Suc 0, [], <m # args>)
((t_wcode_prepare |+| t_wcode_main) |+| t_wcode_adjust) stp
- = (0, [Bk], Oc\<^bsup>Suc m\<^esup> @ Bk # Oc\<^bsup>Suc (bl_bin (<args>))\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ = (0, [Bk], Oc\<up>(Suc m) @ Bk # Oc\<up>(Suc (bl_bin (<args>))) @ Bk\<up>(rn))"
proof -
let ?P1 = "\<lambda> (l, r). l = [] \<and> r = <m # args>"
- let ?Q1 = "\<lambda>(l, r). l = Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- (\<exists>ln rn. r = Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<args>)\<^esup> @ Bk\<^bsup>rn\<^esup>)"
+ let ?Q1 = "\<lambda>(l, r). l = Bk # Oc\<up>(Suc m) \<and>
+ (\<exists>ln rn. r = Bk # Oc # Bk\<up>(ln) @ Bk # Bk # Oc\<up>(bl_bin (<args>)) @ Bk\<up>(rn))"
let ?P2 = ?Q1
let ?Q2 = "\<lambda> (l, r). (wadjust_stop m (bl_bin (<args>) - 1) (l, r))"
let ?P3 = "\<lambda> tp. False"
assume h: "args \<noteq> []"
- have "?P1 \<turnstile>-> \<lambda> tp. (\<exists> stp tp'. steps (Suc 0, tp)
- ((t_wcode_prepare |+| t_wcode_main) |+| t_wcode_adjust) stp = (0, tp') \<and> ?Q2 tp')"
- proof(rule_tac turing_merge.t_merge_halt[of "t_wcode_prepare |+| t_wcode_main"
- t_wcode_adjust ?P1 ?P2 ?P3 ?P3 ?Q1 ?Q2],
- auto simp: turing_merge_def)
-
- show "\<exists>stp. case steps (Suc 0, [], <m # args>) (t_wcode_prepare |+| t_wcode_main) stp of
- (st, tp') \<Rightarrow> st = 0 \<and> (case tp' of (l, r) \<Rightarrow> l = Bk # Oc\<^bsup>Suc m\<^esup> \<and>
- (\<exists>ln rn. r = Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk # Oc\<^bsup>bl_bin (<args>)\<^esup> @ Bk\<^bsup>rn\<^esup>))"
- using h prepare_mainpart_lemma[of args m]
- apply(auto)
- apply(rule_tac x = stp in exI, simp)
- apply(rule_tac x = ln in exI, auto)
+ hence a: "bl_bin (<args>) > 0"
+ using h by simp
+ hence "{?P1} (t_wcode_prepare |+| t_wcode_main) |+| t_wcode_adjust {?Q2}"
+ proof(rule_tac Hoare_plus_halt)
+ show "?Q1 \<mapsto> ?P2"
+ by(simp add: assert_imp_def)
+ next
+ show "tm_wf (t_wcode_prepare |+| t_wcode_main, 0)"
+ apply(rule_tac tm_wf_comp, auto)
done
next
- fix ln rn
- show "\<exists>stp. case steps (Suc 0, Bk # Oc\<^bsup>Suc m\<^esup>, Bk # Oc # Bk\<^bsup>ln\<^esup> @ Bk # Bk #
- Oc\<^bsup>bl_bin (<args>)\<^esup> @ Bk\<^bsup>rn\<^esup>) t_wcode_adjust stp of
- (st, tp') \<Rightarrow> st = 0 \<and> wadjust_stop m (bl_bin (<args>) - Suc 0) tp'"
- using wadjust_correctness[of m "bl_bin (<args>) - 1" "Suc ln" rn]
- apply(subgoal_tac "bl_bin (<args>) > 0", auto simp: wadjust_inv.simps)
- apply(rule_tac x = n in exI, simp add: exp_ind)
- using h
- apply(case_tac args, simp_all, case_tac list,
- simp_all add: tape_of_nl_abv tape_of_nat_list.simps exp_ind_def
- bl_bin.simps)
- done
+ show "{?P1} t_wcode_prepare |+| t_wcode_main {?Q1}"
+ proof(rule_tac HoareI, auto)
+ show
+ "\<exists>n. is_final (steps0 (Suc 0, [], <m # args>) (t_wcode_prepare |+| t_wcode_main) n) \<and>
+ (\<lambda>(l, r). l = Bk # Oc # Oc \<up> m \<and>
+ (\<exists>ln rn. r = Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> bl_bin (<args>) @ Bk \<up> rn))
+ holds_for steps0 (Suc 0, [], <m # args>) (t_wcode_prepare |+| t_wcode_main) n"
+ using h prepare_mainpart_lemma[of args m]
+ apply(auto)
+ apply(rule_tac x = stp in exI, simp)
+ apply(rule_tac x = ln in exI, auto)
+ done
+ qed
next
- show "?Q1 \<turnstile>-> ?P2"
- by(simp add: t_imply_def)
+ show "{?P2} t_wcode_adjust {?Q2}"
+ proof(rule_tac HoareI, auto del: replicate_Suc)
+ fix ln rn
+ show "\<exists>n. is_final (steps0 (Suc 0, Bk # Oc # Oc \<up> m,
+ Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> bl_bin (<args>) @ Bk \<up> rn) t_wcode_adjust n) \<and>
+ wadjust_stop m (bl_bin (<args>) - Suc 0) holds_for steps0
+ (Suc 0, Bk # Oc # Oc \<up> m, Bk # Oc # Bk \<up> ln @ Bk # Bk # Oc \<up> bl_bin (<args>) @ Bk \<up> rn) t_wcode_adjust n"
+ using wadjust_correctness[of m "bl_bin (<args>) - 1" "Suc ln" rn]
+ apply(simp del: replicate_Suc add: replicate_Suc[THEN sym] exp_ind, auto)
+ apply(rule_tac x = n in exI)
+ using a
+ apply(case_tac "bl_bin (<args>)", simp, simp del: replicate_Suc add: exp_ind wadjust_inv.simps)
+ done
+ qed
qed
- thus "\<exists>stp rn. steps (Suc 0, [], <m # args>) ((t_wcode_prepare |+| t_wcode_main) |+|
- t_wcode_adjust) stp = (0, [Bk], Oc\<^bsup>Suc m\<^esup> @ Bk # Oc\<^bsup>Suc (bl_bin (<args>))\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- apply(simp add: t_imply_def)
- apply(erule_tac exE)+
- apply(subgoal_tac "bl_bin (<args>) > 0", auto simp: wadjust_stop.simps)
- using h
- apply(case_tac args, simp_all, case_tac list,
- simp_all add: tape_of_nl_abv tape_of_nat_list.simps exp_ind_def
- bl_bin.simps)
+ thus "?thesis"
+ apply(simp add: Hoare_def, auto)
+ apply(case_tac "(steps0 (Suc 0, [], <(m::nat) # args>)
+ ((t_wcode_prepare |+| t_wcode_main) |+| t_wcode_adjust) n)")
+ apply(rule_tac x = n in exI, auto simp: wadjust_stop.simps)
+ using a
+ apply(case_tac "bl_bin (<args>)", simp_all)
done
qed
-
+
text {*
The initialization TM @{text "t_wcode"}.
*}
-definition t_wcode :: "tprog"
+definition t_wcode :: "instr list"
where
"t_wcode = (t_wcode_prepare |+| t_wcode_main) |+| t_wcode_adjust"
@@ -4541,17 +4590,18 @@
text {*
The correctness of @{text "t_wcode"}.
*}
+
lemma wcode_lemma_1:
"args \<noteq> [] \<Longrightarrow>
- \<exists> stp ln rn. steps (Suc 0, [], <m # args>) (t_wcode) stp =
- (0, [Bk], Oc\<^bsup>Suc m\<^esup> @ Bk # Oc\<^bsup>Suc (bl_bin (<args>))\<^esup> @ Bk\<^bsup>rn\<^esup>)"
-apply(simp add: wcode_lemma_pre' t_wcode_def)
+ \<exists> stp ln rn. steps0 (Suc 0, [], <m # args>) (t_wcode) stp =
+ (0, [Bk], Oc\<up>(Suc m) @ Bk # Oc\<up>(Suc (bl_bin (<args>))) @ Bk\<up>(rn))"
+apply(simp add: wcode_lemma_pre' t_wcode_def del: replicate_Suc)
done
lemma wcode_lemma:
"args \<noteq> [] \<Longrightarrow>
- \<exists> stp ln rn. steps (Suc 0, [], <m # args>) (t_wcode) stp =
- (0, [Bk], <[m ,bl_bin (<args>)]> @ Bk\<^bsup>rn\<^esup>)"
+ \<exists> stp ln rn. steps0 (Suc 0, [], <m # args>) (t_wcode) stp =
+ (0, [Bk], <[m ,bl_bin (<args>)]> @ Bk\<up>(rn))"
using wcode_lemma_1[of args m]
apply(simp add: t_wcode_def tape_of_nl_abv tape_of_nat_list.simps)
done
@@ -4564,39 +4614,38 @@
*}
-definition UTM :: "tprog"
+definition UTM :: "instr list"
where
"UTM = (let (aprog, rs_pos, a_md) = rec_ci rec_F in
let abc_F = aprog [+] dummy_abc (Suc (Suc 0)) in
- (t_wcode |+| (tm_of abc_F @ tMp (Suc (Suc 0)) (start_of (layout_of abc_F)
- (length abc_F) - Suc 0))))"
+ (t_wcode |+| (tm_of abc_F @ shift (mopup (Suc (Suc 0))) (length (tm_of abc_F) div 2))))"
definition F_aprog :: "abc_prog"
where
"F_aprog \<equiv> (let (aprog, rs_pos, a_md) = rec_ci rec_F in
aprog [+] dummy_abc (Suc (Suc 0)))"
-definition F_tprog :: "tprog"
+definition F_tprog :: "instr list"
where
"F_tprog = tm_of (F_aprog)"
-definition t_utm :: "tprog"
+definition t_utm :: "instr list"
where
"t_utm \<equiv>
- (F_tprog) @ tMp (Suc (Suc 0)) (start_of (layout_of (F_aprog))
- (length (F_aprog)) - Suc 0)"
-
-definition UTM_pre :: "tprog"
+ F_tprog @ shift (mopup (Suc (Suc 0))) (length F_tprog div 2)"
+
+definition UTM_pre :: "instr list"
where
"UTM_pre = t_wcode |+| t_utm"
+(*
lemma F_abc_halt_eq:
"\<lbrakk>turing_basic.t_correct tp;
length lm = k;
- steps (Suc 0, Bk\<^bsup>l\<^esup>, <lm>) tp stp = (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup>@Bk\<^bsup>n\<^esup>);
+ steps (Suc 0, Bk\<up>(l), <lm>) tp stp = (0, Bk\<up>(m), Oc\<up>(rs)@Bk\<up>(n));
rs > 0\<rbrakk>
\<Longrightarrow> \<exists> stp m. abc_steps_l (0, [code tp, bl2wc (<lm>)]) (F_aprog) stp =
- (length (F_aprog), code tp # bl2wc (<lm>) # (rs - 1) # 0\<^bsup>m\<^esup>)"
+ (length (F_aprog), code tp # bl2wc (<lm>) # (rs - 1) # 0\<up>(m))"
apply(drule_tac F_t_halt_eq, simp, simp, simp)
apply(case_tac "rec_ci rec_F")
apply(frule_tac abc_append_dummy_complie, simp, simp, erule_tac exE,
@@ -4608,13 +4657,13 @@
lemma F_abc_utm_halt_eq:
"\<lbrakk>rs > 0;
abc_steps_l (0, [code tp, bl2wc (<lm>)]) F_aprog stp =
- (length F_aprog, code tp # bl2wc (<lm>) # (rs - 1) # 0\<^bsup>m\<^esup>)\<rbrakk>
+ (length F_aprog, code tp # bl2wc (<lm>) # (rs - 1) # 0\<up>(m))\<rbrakk>
\<Longrightarrow> \<exists>stp m n.(steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp =
- (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>))"
+ (0, Bk\<up>(m), Oc\<up>(rs) @ Bk\<up>(n)))"
thm abacus_turing_eq_halt
using abacus_turing_eq_halt
[of "layout_of F_aprog" "F_aprog" "F_tprog" "length (F_aprog)"
- "[code tp, bl2wc (<lm>)]" stp "code tp # bl2wc (<lm>) # (rs - 1) # 0\<^bsup>m\<^esup>" "Suc (Suc 0)"
+ "[code tp, bl2wc (<lm>)]" stp "code tp # bl2wc (<lm>) # (rs - 1) # 0\<up>(m)" "Suc (Suc 0)"
"start_of (layout_of (F_aprog)) (length (F_aprog))" "[]" 0]
apply(simp add: F_tprog_def t_utm_def abc_lm_v.simps nth_append)
apply(erule_tac exE)+
@@ -4627,20 +4676,21 @@
lemma t_utm_halt_eq':
"\<lbrakk>turing_basic.t_correct tp;
0 < rs;
- steps (Suc 0, Bk\<^bsup>l\<^esup>, <lm::nat list>) tp stp = (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup>@Bk\<^bsup>n\<^esup>)\<rbrakk>
+ steps (Suc 0, Bk\<up>(l), <lm::nat list>) tp stp = (0, Bk\<up>(m), Oc\<up>(rs)@Bk\<up>(n))\<rbrakk>
\<Longrightarrow> \<exists>stp m n. steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp =
- (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>)"
+ (0, Bk\<up>(m), Oc\<up>(rs) @ Bk\<up>(n))"
apply(drule_tac l = l in F_abc_halt_eq, simp, simp, simp)
apply(erule_tac exE, erule_tac exE)
apply(rule_tac F_abc_utm_halt_eq, simp_all)
done
-
-lemma [simp]: "tinres xs (xs @ Bk\<^bsup>i\<^esup>)"
+*)
+(*
+lemma [simp]: "tinres xs (xs @ Bk\<up>(i))"
apply(auto simp: tinres_def)
done
-lemma [elim]: "\<lbrakk>rs > 0; Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>na\<^esup> = c @ Bk\<^bsup>n\<^esup>\<rbrakk>
- \<Longrightarrow> \<exists>n. c = Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>"
+lemma [elim]: "\<lbrakk>rs > 0; Oc\<up>(rs) @ Bk\<up>(na) = c @ Bk\<up>(n)\<rbrakk>
+ \<Longrightarrow> \<exists>n. c = Oc\<up>(rs) @ Bk\<up>(n)"
apply(case_tac "na > n")
apply(subgoal_tac "\<exists> d. na = d + n", auto simp: exp_add)
apply(rule_tac x = "na - n" in exI, simp)
@@ -4649,29 +4699,29 @@
simp_all add: exp_ind)
apply(rule_tac x = "n - na" in exI, simp)
done
-
-
+*)
+(*
lemma t_utm_halt_eq'':
"\<lbrakk>turing_basic.t_correct tp;
0 < rs;
- steps (Suc 0, Bk\<^bsup>l\<^esup>, <lm::nat list>) tp stp = (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup>@Bk\<^bsup>n\<^esup>)\<rbrakk>
- \<Longrightarrow> \<exists>stp m n. steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>i\<^esup>) t_utm stp =
- (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>)"
+ steps (Suc 0, Bk\<up>(l), <lm::nat list>) tp stp = (0, Bk\<up>(m), Oc\<up>(rs)@Bk\<up>(n))\<rbrakk>
+ \<Longrightarrow> \<exists>stp m n. steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<up>(i)) t_utm stp =
+ (0, Bk\<up>(m), Oc\<up>(rs) @ Bk\<up>(n))"
apply(drule_tac t_utm_halt_eq', simp_all)
apply(erule_tac exE)+
proof -
fix stpa ma na
- assume "steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stpa = (0, Bk\<^bsup>ma\<^esup>, Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>na\<^esup>)"
+ assume "steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stpa = (0, Bk\<up>(ma), Oc\<up>(rs) @ Bk\<up>(na))"
and gr: "rs > 0"
- thus "\<exists>stp m n. steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>i\<^esup>) t_utm stp = (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>)"
+ thus "\<exists>stp m n. steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<up>(i)) t_utm stp = (0, Bk\<up>(m), Oc\<up>(rs) @ Bk\<up>(n))"
apply(rule_tac x = stpa in exI, rule_tac x = ma in exI, simp)
- proof(case_tac "steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>i\<^esup>) t_utm stpa", simp)
+ proof(case_tac "steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<up>(i)) t_utm stpa", simp)
fix a b c
- assume "steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stpa = (0, Bk\<^bsup>ma\<^esup>, Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>na\<^esup>)"
- "steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>i\<^esup>) t_utm stpa = (a, b, c)"
- thus " a = 0 \<and> b = Bk\<^bsup>ma\<^esup> \<and> (\<exists>n. c = Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>)"
- using tinres_steps2[of "<[code tp, bl2wc (<lm>)]>" "<[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>i\<^esup>"
- "Suc 0" " [Bk, Bk]" t_utm stpa 0 "Bk\<^bsup>ma\<^esup>" "Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>na\<^esup>" a b c]
+ assume "steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stpa = (0, Bk\<up>(ma), Oc\<up>(rs) @ Bk\<up>(na))"
+ "steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<up>(i)) t_utm stpa = (a, b, c)"
+ thus " a = 0 \<and> b = Bk\<up>(ma) \<and> (\<exists>n. c = Oc\<up>(rs) @ Bk\<up>(n))"
+ using tinres_steps2[of "<[code tp, bl2wc (<lm>)]>" "<[code tp, bl2wc (<lm>)]> @ Bk\<up>(i)"
+ "Suc 0" " [Bk, Bk]" t_utm stpa 0 "Bk\<up>(ma)" "Oc\<up>(rs) @ Bk\<up>(na)" a b c]
apply(simp)
using gr
apply(simp only: tinres_def, auto)
@@ -4684,99 +4734,195 @@
apply(auto simp: tinres_def)
done
-lemma [elim]: "Bk\<^bsup>ma\<^esup> = b @ Bk\<^bsup>n\<^esup> \<Longrightarrow> \<exists>m. b = Bk\<^bsup>m\<^esup>"
+lemma [elim]: "Bk\<up>(ma) = b @ Bk\<up>(n) \<Longrightarrow> \<exists>m. b = Bk\<up>(m)"
apply(subgoal_tac "ma = length b + n")
apply(rule_tac x = "ma - n" in exI, simp add: exp_add)
apply(drule_tac length_equal)
apply(simp)
done
+*)
+
+
+
+lemma tinres_step1:
+ "\<lbrakk>tinres l l'; step (ss, l, r) (t, 0) = (sa, la, ra);
+ step (ss, l', r) (t, 0) = (sb, lb, rb)\<rbrakk>
+ \<Longrightarrow> tinres la lb \<and> ra = rb \<and> sa = sb"
+apply(case_tac ss, case_tac [!]r, case_tac [!] "a::cell")
+apply(auto simp: step.simps fetch.simps nth_of.simps
+ split: if_splits )
+apply(case_tac [!] "t ! (2 * nat)",
+ auto simp: tinres_def split: if_splits)
+apply(case_tac [1-8] a, auto split: if_splits)
+apply(case_tac [!] "t ! (2 * nat)",
+ auto simp: tinres_def split: if_splits)
+apply(case_tac [1-4] a, auto split: if_splits)
+apply(case_tac [!] "t ! Suc (2 * nat)",
+ auto simp: if_splits)
+apply(case_tac [!] aa, auto split: if_splits)
+done
+
+lemma tinres_steps1:
+ "\<lbrakk>tinres l l'; steps (ss, l, r) (t, 0) stp = (sa, la, ra);
+ steps (ss, l', r) (t, 0) stp = (sb, lb, rb)\<rbrakk>
+ \<Longrightarrow> tinres la lb \<and> ra = rb \<and> sa = sb"
+apply(induct stp arbitrary: sa la ra sb lb rb, simp add: steps.simps)
+apply(simp add: step_red)
+apply(case_tac "(steps (ss, l, r) (t, 0) stp)")
+apply(case_tac "(steps (ss, l', r) (t, 0) stp)")
+proof -
+ fix stp sa la ra sb lb rb a b c aa ba ca
+ assume ind: "\<And>sa la ra sb lb rb. \<lbrakk>steps (ss, l, r) (t, 0) stp = (sa, (la::cell list), ra);
+ steps (ss, l', r) (t, 0) stp = (sb, lb, rb)\<rbrakk> \<Longrightarrow> tinres la lb \<and> ra = rb \<and> sa = sb"
+ and h: " tinres l l'" "step (steps (ss, l, r) (t, 0) stp) (t, 0) = (sa, la, ra)"
+ "step (steps (ss, l', r) (t, 0) stp) (t, 0) = (sb, lb, rb)" "steps (ss, l, r) (t, 0) stp = (a, b, c)"
+ "steps (ss, l', r) (t, 0) stp = (aa, ba, ca)"
+ have "tinres b ba \<and> c = ca \<and> a = aa"
+ apply(rule_tac ind, simp_all add: h)
+ done
+ thus "tinres la lb \<and> ra = rb \<and> sa = sb"
+ apply(rule_tac l = b and l' = ba and r = c and ss = a
+ and t = t in tinres_step1)
+ using h
+ apply(simp, simp, simp)
+ done
+qed
+
+lemma [simp]:
+ "tinres (Bk \<up> m @ [Bk, Bk]) la \<Longrightarrow> \<exists>m. la = Bk \<up> m"
+apply(auto simp: tinres_def)
+apply(case_tac n, simp add: exp_ind)
+apply(rule_tac x ="Suc (Suc m)" in exI, simp only: exp_ind, simp)
+apply(simp add: exp_ind del: replicate_Suc)
+apply(case_tac nat, simp add: exp_ind)
+apply(rule_tac x = "Suc m" in exI, simp only: exp_ind)
+apply(simp only: exp_ind, simp)
+apply(subgoal_tac "m = length la + nata")
+apply(rule_tac x = "m - nata" in exI, simp add: exp_add)
+apply(drule_tac length_equal, simp)
+apply(simp only: exp_ind[THEN sym] replicate_Suc[THEN sym] replicate_add[THEN sym])
+apply(rule_tac x = "m + Suc (Suc n)" in exI, simp)
+done
lemma t_utm_halt_eq:
- "\<lbrakk>turing_basic.t_correct tp;
- 0 < rs;
- steps (Suc 0, Bk\<^bsup>l\<^esup>, <lm::nat list>) tp stp = (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup>@Bk\<^bsup>n\<^esup>)\<rbrakk>
- \<Longrightarrow> \<exists>stp m n. steps (Suc 0, [Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>i\<^esup>) t_utm stp =
- (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>)"
-apply(drule_tac i = i in t_utm_halt_eq'', simp_all)
-apply(erule_tac exE)+
+ assumes tm_wf: "tm_wf (tp, 0)"
+ and exec: "steps0 (Suc 0, Bk\<up>(l), <lm::nat list>) tp stp = (0, Bk\<up>(m), Oc\<up>(rs)@Bk\<up>(n))"
+ and resutl: "0 < rs"
+ shows "\<exists>stp m n. steps0 (Suc 0, [Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<up>(i)) t_utm stp =
+ (0, Bk\<up>(m), Oc\<up>(rs) @ Bk\<up>(n))"
proof -
- fix stpa ma na
- assume "steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>i\<^esup>) t_utm stpa = (0, Bk\<^bsup>ma\<^esup>, Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>na\<^esup>)"
- and gr: "rs > 0"
- thus "\<exists>stp m n. steps (Suc 0, [Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>i\<^esup>) t_utm stp = (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>)"
- apply(rule_tac x = stpa in exI)
- proof(case_tac "steps (Suc 0, [Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>i\<^esup>) t_utm stpa", simp)
- fix a b c
- assume "steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>i\<^esup>) t_utm stpa = (0, Bk\<^bsup>ma\<^esup>, Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>na\<^esup>)"
- "steps (Suc 0, [Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>i\<^esup>) t_utm stpa = (a, b, c)"
- thus "a = 0 \<and> (\<exists>m. b = Bk\<^bsup>m\<^esup>) \<and> (\<exists>n. c = Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>)"
- using tinres_steps[of "[Bk, Bk]" "[Bk]" "Suc 0" "<[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>i\<^esup>" t_utm stpa 0
- "Bk\<^bsup>ma\<^esup>" "Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>na\<^esup>" a b c]
- apply(simp)
- apply(auto simp: tinres_def)
- apply(rule_tac x = "ma + n" in exI, simp add: exp_add)
+ obtain ap arity fp where a: "rec_ci rec_F = (ap, arity, fp)"
+ by (metis prod_cases3)
+ moreover have b: "rec_calc_rel rec_F [code tp, (bl2wc (<lm>))] (rs - Suc 0)"
+ using assms
+ apply(rule_tac F_correct, simp_all)
+ done
+ have "\<exists> stp m l. steps0 (Suc 0, Bk # Bk # [], <[code tp, bl2wc (<lm>)]> @ Bk\<up>i)
+ (F_tprog @ shift (mopup 2) (length F_tprog div 2)) stp
+ = (0, Bk\<up>m @ Bk # Bk # [], Oc\<up>Suc (rs - 1) @ Bk\<up>l)"
+ proof(rule_tac recursive_compile_to_tm_correct)
+ show "rec_ci rec_F = (ap, arity, fp)" using a by simp
+ next
+ show "rec_calc_rel rec_F [code tp, bl2wc (<lm>)] (rs - 1)"
+ using b by simp
+ next
+ show "length [code tp, bl2wc (<lm>)] = 2" by simp
+ next
+ show "layout_of (ap [+] dummy_abc 2) = layout_of (ap [+] dummy_abc 2)"
+ by simp
+ next
+ show "F_tprog = tm_of (ap [+] dummy_abc 2)"
+ using a
+ apply(simp add: F_tprog_def F_aprog_def numeral_2_eq_2)
done
qed
+ then obtain stp m l where
+ "steps0 (Suc 0, Bk # Bk # [], <[code tp, bl2wc (<lm>)]> @ Bk\<up>i)
+ (F_tprog @ shift (mopup 2) (length F_tprog div 2)) stp
+ = (0, Bk\<up>m @ Bk # Bk # [], Oc\<up>Suc (rs - 1) @ Bk\<up>l)" by blast
+ hence "\<exists> m. steps0 (Suc 0, [Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<up>i)
+ (F_tprog @ shift (mopup 2) (length F_tprog div 2)) stp
+ = (0, Bk\<up>m, Oc\<up>Suc (rs - 1) @ Bk\<up>l)"
+ proof -
+ assume g: "steps0 (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]> @ Bk \<up> i)
+ (F_tprog @ shift (mopup 2) (length F_tprog div 2)) stp =
+ (0, Bk \<up> m @ [Bk, Bk], Oc \<up> Suc (rs - 1) @ Bk \<up> l)"
+ moreover have "tinres [Bk, Bk] [Bk]"
+ apply(auto simp: tinres_def)
+ done
+ moreover obtain sa la ra where "steps0 (Suc 0, [Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<up>i)
+ (F_tprog @ shift (mopup 2) (length F_tprog div 2)) stp = (sa, la, ra)"
+ apply(case_tac "steps0 (Suc 0, [Bk], <[code tp, bl2wc (<lm>)]> @ Bk\<up>i)
+ (F_tprog @ shift (mopup 2) (length F_tprog div 2)) stp", auto)
+ done
+ ultimately show "?thesis"
+ apply(drule_tac tinres_steps1, auto)
+ done
+ qed
+ thus "?thesis"
+ apply(auto)
+ apply(rule_tac x = stp in exI, simp add: t_utm_def)
+ using assms
+ apply(case_tac rs, simp_all add: numeral_2_eq_2)
+ done
qed
-lemma [intro]: "t_correct t_wcode"
+lemma [intro]: "tm_wf (t_wcode, 0)"
apply(simp add: t_wcode_def)
-apply(auto)
+apply(rule_tac tm_wf_comp)
+apply(rule_tac tm_wf_comp, auto)
done
-lemma [intro]: "t_correct t_utm"
-apply(simp add: t_utm_def F_tprog_def)
+lemma [intro]: "tm_wf (t_utm, 0)"
+apply(simp only: t_utm_def F_tprog_def)
apply(rule_tac t_compiled_correct, auto)
done
lemma UTM_halt_lemma_pre:
- "\<lbrakk>turing_basic.t_correct tp;
- 0 < rs;
- args \<noteq> [];
- steps (Suc 0, Bk\<^bsup>i\<^esup>, <args::nat list>) tp stp = (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup>@Bk\<^bsup>k\<^esup>)\<rbrakk>
- \<Longrightarrow> \<exists>stp m n. steps (Suc 0, [], <code tp # args>) UTM_pre stp =
- (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>)"
+ assumes wf_tm: "tm_wf (tp, 0)"
+ and result: "0 < rs"
+ and args: "args \<noteq> []"
+ and exec: "steps0 (Suc 0, Bk\<up>(i), <args::nat list>) tp stp = (0, Bk\<up>(m), Oc\<up>(rs)@Bk\<up>(k))"
+ shows "\<exists>stp m n. steps0 (Suc 0, [], <code tp # args>) UTM_pre stp =
+ (0, Bk\<up>(m), Oc\<up>(rs) @ Bk\<up>(n))"
proof -
- let ?Q2 = "\<lambda> (l, r). (\<exists> ln rn. l = Bk\<^bsup>ln\<^esup> \<and> r = Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>rn\<^esup>)"
- term ?Q2
+ let ?Q2 = "\<lambda> (l, r). (\<exists> ln rn. l = Bk\<up>(ln) \<and> r = Oc\<up>(rs) @ Bk\<up>(rn))"
let ?P1 = "\<lambda> (l, r). l = [] \<and> r = <code tp # args>"
let ?Q1 = "\<lambda> (l, r). (l = [Bk] \<and>
- (\<exists> rn. r = Oc\<^bsup>Suc (code tp)\<^esup> @ Bk # Oc\<^bsup>Suc (bl_bin (<args>))\<^esup> @ Bk\<^bsup>rn\<^esup>))"
+ (\<exists> rn. r = Oc\<up>(Suc (code tp)) @ Bk # Oc\<up>(Suc (bl_bin (<args>))) @ Bk\<up>(rn)))"
let ?P2 = ?Q1
let ?P3 = "\<lambda> (l, r). False"
- assume h: "turing_basic.t_correct tp" "0 < rs"
- "args \<noteq> []" "steps (Suc 0, Bk\<^bsup>i\<^esup>, <args::nat list>) tp stp = (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup>@Bk\<^bsup>k\<^esup>)"
- have "?P1 \<turnstile>-> \<lambda> tp. (\<exists> stp tp'. steps (Suc 0, tp)
- (t_wcode |+| t_utm) stp = (0, tp') \<and> ?Q2 tp')"
- proof(rule_tac turing_merge.t_merge_halt [of "t_wcode" "t_utm"
- ?P1 ?P2 ?P3 ?P3 ?Q1 ?Q2], auto simp: turing_merge_def)
- show "\<exists>stp. case steps (Suc 0, [], <code tp # args>) t_wcode stp of (st, tp') \<Rightarrow>
- st = 0 \<and> (case tp' of (l, r) \<Rightarrow> l = [Bk] \<and>
- (\<exists>rn. r = Oc\<^bsup>Suc (code tp)\<^esup> @ Bk # Oc\<^bsup>Suc (bl_bin (<args>))\<^esup> @ Bk\<^bsup>rn\<^esup>))"
- using wcode_lemma_1[of args "code tp"] h
- apply(simp, auto)
- apply(rule_tac x = stpa in exI, auto)
- done
+ have "{?P1} (t_wcode |+| t_utm) {?Q2}"
+ proof(rule_tac Hoare_plus_halt)
+ show "?Q1 \<mapsto> ?P2"
+ by(simp add: assert_imp_def)
next
- fix rn
- show "\<exists>stp. case steps (Suc 0, [Bk], Oc\<^bsup>Suc (code tp)\<^esup> @
- Bk # Oc\<^bsup>Suc (bl_bin (<args>))\<^esup> @ Bk\<^bsup>rn\<^esup>) t_utm stp of
- (st, tp') \<Rightarrow> st = 0 \<and> (case tp' of (l, r) \<Rightarrow>
- (\<exists>ln. l = Bk\<^bsup>ln\<^esup>) \<and> (\<exists>rn. r = Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>rn\<^esup>))"
- using t_utm_halt_eq[of tp rs i args stp m k rn] h
+ show "tm_wf (t_wcode, 0)" by auto
+ next
+ show "{?P1} t_wcode {?Q1}"
+ apply(rule_tac HoareI, auto)
+ using wcode_lemma_1[of args "code tp"] args
apply(auto)
- apply(rule_tac x = stpa in exI, simp add: bin_wc_eq
- tape_of_nat_list.simps tape_of_nl_abv)
- apply(auto)
+ apply(rule_tac x = stp in exI, simp)
done
next
- show "?Q1 \<turnstile>-> ?P2"
- apply(simp add: t_imply_def)
+ show "{?P2} t_utm {?Q2}"
+ proof(rule_tac HoareI, auto)
+ fix rn
+ show "\<exists>n. is_final (steps0 (Suc 0, [Bk], Oc # Oc \<up> code tp @ Bk # Oc # Oc \<up> bl_bin (<args>) @ Bk \<up> rn) t_utm n) \<and>
+ (\<lambda>(l, r). (\<exists>ln. l = Bk \<up> ln) \<and>
+ (\<exists>rn. r = Oc \<up> rs @ Bk \<up> rn)) holds_for steps0 (Suc 0, [Bk],
+ Oc # Oc \<up> code tp @ Bk # Oc # Oc \<up> bl_bin (<args>) @ Bk \<up> rn) t_utm n"
+ using t_utm_halt_eq[of tp i "args" stp m rs k rn] assms
+ apply(auto simp: bin_wc_eq)
+ apply(rule_tac x = stpa in exI, simp add: tape_of_nl_abv)
done
+ qed
qed
thus "?thesis"
- apply(simp add: t_imply_def)
- apply(auto simp: UTM_pre_def)
+ apply(auto simp: Hoare_def UTM_pre_def)
+ apply(case_tac "steps0 (Suc 0, [], <code tp # args>) (t_wcode |+| t_utm) n")
+ apply(rule_tac x = n in exI, simp)
done
qed
@@ -4784,84 +4930,81 @@
The correctness of @{text "UTM"}, the halt case.
*}
lemma UTM_halt_lemma:
- "\<lbrakk>turing_basic.t_correct tp;
- 0 < rs;
- args \<noteq> [];
- steps (Suc 0, Bk\<^bsup>i\<^esup>, <args::nat list>) tp stp = (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup>@Bk\<^bsup>k\<^esup>)\<rbrakk>
- \<Longrightarrow> \<exists>stp m n. steps (Suc 0, [], <code tp # args>) UTM stp =
- (0, Bk\<^bsup>m\<^esup>, Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>)"
-using UTM_halt_lemma_pre[of tp rs args i stp m k]
+ assumes tm_wf: "tm_wf (tp, 0)"
+ and result: "0 < rs"
+ and args: "args \<noteq> []"
+ and exec: "steps0 (Suc 0, Bk\<up>(i), <args::nat list>) tp stp = (0, Bk\<up>(m), Oc\<up>(rs)@Bk\<up>(k))"
+ shows "\<exists>stp m n. steps0 (Suc 0, [], <code tp # args>) UTM stp =
+ (0, Bk\<up>(m), Oc\<up>(rs) @ Bk\<up>(n))"
+using UTM_halt_lemma_pre[of tp rs args i stp m k] assms
apply(simp add: UTM_pre_def t_utm_def UTM_def F_aprog_def F_tprog_def)
apply(case_tac "rec_ci rec_F", simp)
done
-definition TSTD:: "t_conf \<Rightarrow> bool"
+definition TSTD:: "config \<Rightarrow> bool"
where
"TSTD c = (let (st, l, r) = c in
- st = 0 \<and> (\<exists> m. l = Bk\<^bsup>m\<^esup>) \<and> (\<exists> rs n. r = Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>))"
-
-thm abacus_turing_eq_uhalt
+ st = 0 \<and> (\<exists> m. l = Bk\<up>(m)) \<and> (\<exists> rs n. r = Oc\<up>(Suc rs) @ Bk\<up>(n)))"
lemma nstd_case1: "0 < a \<Longrightarrow> NSTD (trpl_code (a, b, c))"
apply(simp add: NSTD.simps trpl_code.simps)
done
-lemma [simp]: "\<forall>m. b \<noteq> Bk\<^bsup>m\<^esup> \<Longrightarrow> 0 < bl2wc b"
+lemma [simp]: "\<forall>m. b \<noteq> Bk\<up>(m) \<Longrightarrow> 0 < bl2wc b"
apply(rule classical, simp)
apply(induct b, erule_tac x = 0 in allE, simp)
apply(simp add: bl2wc.simps, case_tac a, simp_all
add: bl2nat.simps bl2nat_double)
-apply(case_tac "\<exists> m. b = Bk\<^bsup>m\<^esup>", erule exE)
-apply(erule_tac x = "Suc m" in allE, simp add: exp_ind_def, simp)
-done
-lemma nstd_case2: "\<forall>m. b \<noteq> Bk\<^bsup>m\<^esup> \<Longrightarrow> NSTD (trpl_code (a, b, c))"
+apply(case_tac "\<exists> m. b = Bk\<up>(m)", erule exE)
+apply(erule_tac x = "Suc m" in allE, simp add: , simp)
+done
+
+lemma nstd_case2: "\<forall>m. b \<noteq> Bk\<up>(m) \<Longrightarrow> NSTD (trpl_code (a, b, c))"
apply(simp add: NSTD.simps trpl_code.simps)
done
-thm lg.simps
-thm lgR.simps
-
lemma [elim]: "Suc (2 * x) = 2 * y \<Longrightarrow> RR"
apply(induct x arbitrary: y, simp, simp)
apply(case_tac y, simp, simp)
done
-lemma bl2nat_zero_eq[simp]: "(bl2nat c 0 = 0) = (\<exists>n. c = Bk\<^bsup>n\<^esup>)"
+declare replicate_Suc[simp del]
+
+lemma bl2nat_zero_eq[simp]: "(bl2nat c 0 = 0) = (\<exists>n. c = Bk\<up>(n))"
apply(auto)
-apply(induct c, simp add: bl2nat.simps)
-apply(rule_tac x = 0 in exI, simp)
+apply(induct c, simp_all add: bl2nat.simps)
apply(case_tac a, auto simp: bl2nat.simps bl2nat_double)
done
lemma bl2wc_exp_ex:
- "\<lbrakk>Suc (bl2wc c) = 2 ^ m\<rbrakk> \<Longrightarrow> \<exists> rs n. c = Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>"
+ "\<lbrakk>Suc (bl2wc c) = 2 ^ m\<rbrakk> \<Longrightarrow> \<exists> rs n. c = Oc\<up>(rs) @ Bk\<up>(n)"
apply(induct c arbitrary: m, simp add: bl2wc.simps bl2nat.simps)
apply(case_tac a, auto)
apply(case_tac m, simp_all add: bl2wc.simps, auto)
apply(rule_tac x = 0 in exI, rule_tac x = "Suc n" in exI,
- simp add: exp_ind_def)
+ simp add: replicate_Suc)
apply(simp add: bl2wc.simps bl2nat.simps bl2nat_double)
apply(case_tac m, simp, simp)
proof -
fix c m nat
assume ind:
- "\<And>m. Suc (bl2nat c 0) = 2 ^ m \<Longrightarrow> \<exists>rs n. c = Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>"
+ "\<And>m. Suc (bl2nat c 0) = 2 ^ m \<Longrightarrow> \<exists>rs n. c = Oc\<up>(rs) @ Bk\<up>(n)"
and h:
"Suc (Suc (2 * bl2nat c 0)) = 2 * 2 ^ nat"
- have "\<exists>rs n. c = Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>"
+ have "\<exists>rs n. c = Oc\<up>(rs) @ Bk\<up>(n)"
apply(rule_tac m = nat in ind)
using h
apply(simp)
done
- from this obtain rs n where " c = Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>" by blast
- thus "\<exists>rs n. Oc # c = Oc\<^bsup>rs\<^esup> @ Bk\<^bsup>n\<^esup>"
- apply(rule_tac x = "Suc rs" in exI, simp add: exp_ind_def)
- apply(rule_tac x = n in exI, simp)
+ from this obtain rs n where " c = Oc\<up>(rs) @ Bk\<up>(n)" by blast
+ thus "\<exists>rs n. Oc # c = Oc\<up>(rs) @ Bk\<up>(n)"
+ apply(rule_tac x = "Suc rs" in exI, simp add: )
+ apply(rule_tac x = n in exI, simp add: replicate_Suc)
done
qed
-lemma [elim]:
- "\<lbrakk>\<forall>rs n. c \<noteq> Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup>;
+lemma lg_bin:
+ "\<lbrakk>\<forall>rs n. c \<noteq> Oc\<up>(Suc rs) @ Bk\<up>(n);
bl2wc c = 2 ^ lg (Suc (bl2wc c)) 2 - Suc 0\<rbrakk> \<Longrightarrow> bl2wc c = 0"
apply(subgoal_tac "\<exists> m. Suc (bl2wc c) = 2^m", erule_tac exE)
apply(drule_tac bl2wc_exp_ex, simp, erule_tac exE, erule_tac exE)
@@ -4876,10 +5019,10 @@
done
lemma nstd_case3:
- "\<forall>rs n. c \<noteq> Oc\<^bsup>Suc rs\<^esup> @ Bk\<^bsup>n\<^esup> \<Longrightarrow> NSTD (trpl_code (a, b, c))"
+ "\<forall>rs n. c \<noteq> Oc\<up>(Suc rs) @ Bk\<up>(n) \<Longrightarrow> NSTD (trpl_code (a, b, c))"
apply(simp add: NSTD.simps trpl_code.simps)
-apply(rule_tac impI)
-apply(rule_tac disjI2, rule_tac disjI2, auto)
+apply(auto)
+apply(drule_tac lg_bin, simp_all)
done
lemma NSTD_1: "\<not> TSTD (a, b, c)
@@ -4893,10 +5036,10 @@
done
lemma nonstop_t_uhalt_eq:
- "\<lbrakk>turing_basic.t_correct tp;
- steps (Suc 0, Bk\<^bsup>l\<^esup>, <lm>) tp stp = (a, b, c);
- \<not> TSTD (a, b, c)\<rbrakk>
- \<Longrightarrow> rec_exec rec_nonstop [code tp, bl2wc (<lm>), stp] = Suc 0"
+ "\<lbrakk>tm_wf (tp, 0);
+ steps0 (Suc 0, Bk\<up>(l), <lm>) tp stp = (a, b, c);
+ \<not> TSTD (a, b, c)\<rbrakk>
+ \<Longrightarrow> rec_exec rec_nonstop [code tp, bl2wc (<lm>), stp] = Suc 0"
apply(simp add: rec_nonstop_def rec_exec.simps)
apply(subgoal_tac
"rec_exec rec_conf [code tp, bl2wc (<lm>), stp] =
@@ -4907,12 +5050,12 @@
done
lemma nonstop_true:
- "\<lbrakk>turing_basic.t_correct tp;
- \<forall> stp. (\<not> TSTD (steps (Suc 0, Bk\<^bsup>l\<^esup>, <lm>) tp stp))\<rbrakk>
- \<Longrightarrow> \<forall>y. rec_calc_rel rec_nonstop
- ([code tp, bl2wc (<lm>), y]) (Suc 0)"
+ "\<lbrakk>tm_wf (tp, 0);
+ \<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <lm>) tp stp))\<rbrakk>
+ \<Longrightarrow> \<forall>y. rec_calc_rel rec_nonstop
+ ([code tp, bl2wc (<lm>), y]) (Suc 0)"
apply(rule_tac allI, erule_tac x = y in allE)
-apply(case_tac "steps (Suc 0, Bk\<^bsup>l\<^esup>, <lm>) tp y", simp)
+apply(case_tac "steps0 (Suc 0, Bk\<up>(l), <lm>) tp y", simp)
apply(rule_tac nonstop_t_uhalt_eq, simp_all)
done
@@ -4928,10 +5071,10 @@
declare ci_cn_para_eq[simp]
lemma F_aprog_uhalt:
- "\<lbrakk>turing_basic.t_correct tp;
- \<forall> stp. (\<not> TSTD (steps (Suc 0, Bk\<^bsup>l\<^esup>, <lm>) tp stp));
+ "\<lbrakk>tm_wf (tp,0);
+ \<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <lm>) tp stp));
rec_ci rec_F = (F_ap, rs_pos, a_md)\<rbrakk>
- \<Longrightarrow> \<forall> stp. case abc_steps_l (0, [code tp, bl2wc (<lm>)] @ 0\<^bsup>a_md - rs_pos \<^esup>
+ \<Longrightarrow> \<forall> stp. case abc_steps_l (0, [code tp, bl2wc (<lm>)] @ 0\<up>(a_md - rs_pos )
@ suflm) (F_ap) stp of (ss, e) \<Rightarrow> ss < length (F_ap)"
apply(case_tac "rec_ci (Cn (Suc (Suc 0)) rec_right [Cn (Suc (Suc 0)) rec_conf
([id (Suc (Suc 0)) 0, id (Suc (Suc 0)) (Suc 0), rec_halt])])")
@@ -4974,11 +5117,9 @@
apply(simp)
done
-thm abc_list_crsp_steps
-
lemma uabc_uhalt':
- "\<lbrakk>turing_basic.t_correct tp;
- \<forall> stp. (\<not> TSTD (steps (Suc 0, Bk\<^bsup>l\<^esup>, <lm>) tp stp));
+ "\<lbrakk>tm_wf (tp, 0);
+ \<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <lm>) tp stp));
rec_ci rec_F = (ap, pos, md)\<rbrakk>
\<Longrightarrow> \<forall> stp. case abc_steps_l (0, [code tp, bl2wc (<lm>)]) ap stp of (ss, e)
\<Rightarrow> ss < length ap"
@@ -4986,20 +5127,20 @@
and suflm = "[]" in F_aprog_uhalt, auto)
fix stp a b
assume h:
- "\<forall>stp. case abc_steps_l (0, code tp # bl2wc (<lm>) # 0\<^bsup>md - pos\<^esup>) ap stp of
+ "\<forall>stp. case abc_steps_l (0, code tp # bl2wc (<lm>) # 0\<up>(md - pos)) ap stp of
(ss, e) \<Rightarrow> ss < length ap"
"abc_steps_l (0, [code tp, bl2wc (<lm>)]) ap stp = (a, b)"
- "turing_basic.t_correct tp"
+ "tm_wf (tp, 0)"
"rec_ci rec_F = (ap, pos, md)"
moreover have "ap \<noteq> []"
using h apply(rule_tac rec_ci_not_null, simp)
done
ultimately show "a < length ap"
proof(erule_tac x = stp in allE,
- case_tac "abc_steps_l (0, code tp # bl2wc (<lm>) # 0\<^bsup>md - pos\<^esup>) ap stp", simp)
+ case_tac "abc_steps_l (0, code tp # bl2wc (<lm>) # 0\<up>(md - pos)) ap stp", simp)
fix aa ba
assume g: "aa < length ap"
- "abc_steps_l (0, code tp # bl2wc (<lm>) # 0\<^bsup>md - pos\<^esup>) ap stp = (aa, ba)"
+ "abc_steps_l (0, code tp # bl2wc (<lm>) # 0\<up>(md - pos)) ap stp = (aa, ba)"
"ap \<noteq> []"
thus "?thesis"
using abc_list_crsp_steps[of "[code tp, bl2wc (<lm>)]"
@@ -5010,8 +5151,8 @@
qed
lemma uabc_uhalt:
- "\<lbrakk>turing_basic.t_correct tp;
- \<forall> stp. (\<not> TSTD (steps (Suc 0, Bk\<^bsup>l\<^esup>, <lm>) tp stp))\<rbrakk>
+ "\<lbrakk>tm_wf (tp, 0);
+ \<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <lm>) tp stp))\<rbrakk>
\<Longrightarrow> \<forall> stp. case abc_steps_l (0, [code tp, bl2wc (<lm>)]) F_aprog
stp of (ss, e) \<Rightarrow> ss < length F_aprog"
apply(case_tac "rec_ci rec_F", simp add: F_aprog_def)
@@ -5034,41 +5175,46 @@
qed
lemma tutm_uhalt':
- "\<lbrakk>turing_basic.t_correct tp;
- \<forall> stp. (\<not> TSTD (steps (Suc 0, Bk\<^bsup>l\<^esup>, <lm>) tp stp))\<rbrakk>
- \<Longrightarrow> \<forall> stp. \<not> isS0 (steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp)"
- using abacus_turing_eq_uhalt[of "layout_of (F_aprog)"
- "F_aprog" "F_tprog" "[code tp, bl2wc (<lm>)]"
- "start_of (layout_of (F_aprog )) (length (F_aprog))"
- "Suc (Suc 0)"]
-apply(simp add: F_tprog_def)
-apply(subgoal_tac "\<forall>stp. case abc_steps_l (0, [code tp, bl2wc (<lm>)])
- (F_aprog) stp of (as, am) \<Rightarrow> as < length (F_aprog)", simp)
-thm abacus_turing_eq_uhalt
-apply(simp add: t_utm_def F_tprog_def)
-apply(rule_tac uabc_uhalt, simp_all)
-done
-
+assumes tm_wf: "tm_wf (tp,0)"
+ and unhalt: "\<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <lm>) tp stp))"
+ shows "\<forall> stp. \<not> is_final (steps0 (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp)"
+apply(simp add: t_utm_def)
+proof(rule_tac compile_correct_unhalt)
+ show "layout_of F_aprog = layout_of F_aprog" by simp
+next
+ show "F_tprog = tm_of F_aprog"
+ by(simp add: F_tprog_def)
+next
+ show "crsp (layout_of F_aprog) (0, [code tp, bl2wc (<lm>)]) (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) []"
+ by(auto simp: crsp.simps start_of.simps)
+next
+ show "length F_tprog div 2 = length F_tprog div 2" by simp
+next
+ show "\<forall>stp. case abc_steps_l (0, [code tp, bl2wc (<lm>)]) F_aprog stp of (as, am) \<Rightarrow> as < length F_aprog"
+ using assms
+ apply(erule_tac uabc_uhalt, simp)
+ done
+qed
+
+
lemma tinres_commute: "tinres r r' \<Longrightarrow> tinres r' r"
apply(auto simp: tinres_def)
done
lemma inres_tape:
- "\<lbrakk>steps (st, l, r) tp stp = (a, b, c); steps (st, l', r') tp stp = (a', b', c');
+ "\<lbrakk>steps0 (st, l, r) tp stp = (a, b, c); steps0 (st, l', r') tp stp = (a', b', c');
tinres l l'; tinres r r'\<rbrakk>
\<Longrightarrow> a = a' \<and> tinres b b' \<and> tinres c c'"
-proof(case_tac "steps (st, l', r) tp stp")
+proof(case_tac "steps0 (st, l', r) tp stp")
fix aa ba ca
- assume h: "steps (st, l, r) tp stp = (a, b, c)"
- "steps (st, l', r') tp stp = (a', b', c')"
+ assume h: "steps0 (st, l, r) tp stp = (a, b, c)"
+ "steps0 (st, l', r') tp stp = (a', b', c')"
"tinres l l'" "tinres r r'"
- "steps (st, l', r) tp stp = (aa, ba, ca)"
+ "steps0 (st, l', r) tp stp = (aa, ba, ca)"
have "tinres b ba \<and> c = ca \<and> a = aa"
using h
- apply(rule_tac tinres_steps, auto)
+ apply(rule_tac tinres_steps1, auto)
done
-
- thm tinres_steps2
moreover have "b' = ba \<and> tinres c' ca \<and> a' = aa"
using h
apply(rule_tac tinres_steps2, auto intro: tinres_commute)
@@ -5078,73 +5224,70 @@
done
qed
-lemma tape_normalize: "\<forall> stp. \<not> isS0 (steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp)
- \<Longrightarrow> \<forall> stp. \<not> isS0 (steps (Suc 0, Bk\<^bsup>m\<^esup>, <[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>n\<^esup>) t_utm stp)"
-apply(rule_tac allI, case_tac "(steps (Suc 0, Bk\<^bsup>m\<^esup>,
- <[code tp, bl2wc (<lm>)]> @ Bk\<^bsup>n\<^esup>) t_utm stp)", simp add: isS0_def)
+lemma tape_normalize: "\<forall> stp. \<not> is_final(steps0 (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp)
+ \<Longrightarrow> \<forall> stp. \<not> is_final (steps0 (Suc 0, Bk\<up>(m), <[code tp, bl2wc (<lm>)]> @ Bk\<up>(n)) t_utm stp)"
+apply(rule_tac allI, case_tac "(steps0 (Suc 0, Bk\<up>(m),
+ <[code tp, bl2wc (<lm>)]> @ Bk\<up>(n)) t_utm stp)", simp)
apply(erule_tac x = stp in allE)
-apply(case_tac "steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp", simp)
+apply(case_tac "steps0 (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp", simp)
apply(drule_tac inres_tape, auto)
apply(auto simp: tinres_def)
apply(case_tac "m > Suc (Suc 0)")
apply(rule_tac x = "m - Suc (Suc 0)" in exI)
-apply(case_tac m, simp_all add: exp_ind_def, case_tac nat, simp_all add: exp_ind_def)
-apply(rule_tac x = "2 - m" in exI, simp add: exp_ind_def[THEN sym] exp_add[THEN sym])
-apply(simp only: numeral_2_eq_2, simp add: exp_ind_def)
+apply(case_tac m, simp_all add: , case_tac nat, simp_all add: replicate_Suc)
+apply(rule_tac x = "2 - m" in exI, simp add: exp_add[THEN sym])
+apply(simp only: numeral_2_eq_2, simp add: replicate_Suc)
done
lemma tutm_uhalt:
- "\<lbrakk>turing_basic.t_correct tp;
- \<forall> stp. (\<not> TSTD (steps (Suc 0, Bk\<^bsup>l\<^esup>, <args>) tp stp))\<rbrakk>
- \<Longrightarrow> \<forall> stp. \<not> isS0 (steps (Suc 0, Bk\<^bsup>m\<^esup>, <[code tp, bl2wc (<args>)]> @ Bk\<^bsup>n\<^esup>) t_utm stp)"
+ "\<lbrakk>tm_wf (tp,0);
+ \<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <args>) tp stp))\<rbrakk>
+ \<Longrightarrow> \<forall> stp. \<not> is_final (steps0 (Suc 0, Bk\<up>(m), <[code tp, bl2wc (<args>)]> @ Bk\<up>(n)) t_utm stp)"
apply(rule_tac tape_normalize)
apply(rule_tac tutm_uhalt', simp_all)
done
lemma UTM_uhalt_lemma_pre:
- "\<lbrakk>turing_basic.t_correct tp;
- \<forall> stp. (\<not> TSTD (steps (Suc 0, Bk\<^bsup>l\<^esup>, <args>) tp stp));
- args \<noteq> []\<rbrakk>
- \<Longrightarrow> \<forall> stp. \<not> isS0 (steps (Suc 0, [], <code tp # args>) UTM_pre stp)"
+ assumes tm_wf: "tm_wf (tp, 0)"
+ and exec: "\<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <args>) tp stp))"
+ and args: "args \<noteq> []"
+ shows "\<forall> stp. \<not> is_final (steps0 (Suc 0, [], <code tp # args>) UTM_pre stp)"
proof -
let ?P1 = "\<lambda> (l, r). l = [] \<and> r = <code tp # args>"
let ?Q1 = "\<lambda> (l, r). (l = [Bk] \<and>
- (\<exists> rn. r = Oc\<^bsup>Suc (code tp)\<^esup> @ Bk # Oc\<^bsup>Suc (bl_bin (<args>))\<^esup> @ Bk\<^bsup>rn\<^esup>))"
- let ?P4 = ?Q1
- let ?P3 = "\<lambda> (l, r). False"
- assume h: "turing_basic.t_correct tp" "\<forall>stp. \<not> TSTD (steps (Suc 0, Bk\<^bsup>l\<^esup>, <args>) tp stp)"
- "args \<noteq> []"
- have "?P1 \<turnstile>-> \<lambda> tp. \<not> (\<exists> stp. isS0 (steps (Suc 0, tp) (t_wcode |+| t_utm) stp))"
- proof(rule_tac turing_merge.t_merge_uhalt [of "t_wcode" "t_utm"
- ?P1 ?P3 ?P3 ?P4 ?Q1 ?P3], auto simp: turing_merge_def)
- show "\<exists>stp. case steps (Suc 0, [], <code tp # args>) t_wcode stp of (st, tp') \<Rightarrow>
- st = 0 \<and> (case tp' of (l, r) \<Rightarrow> l = [Bk] \<and>
- (\<exists>rn. r = Oc\<^bsup>Suc (code tp)\<^esup> @ Bk # Oc\<^bsup>Suc (bl_bin (<args>))\<^esup> @ Bk\<^bsup>rn\<^esup>))"
- using wcode_lemma_1[of args "code tp"] h
- apply(simp, auto)
- apply(rule_tac x = stp in exI, auto)
- done
+ (\<exists> rn. r = Oc\<up>(Suc (code tp)) @ Bk # Oc\<up>(Suc (bl_bin (<args>))) @ Bk\<up>(rn)))"
+ let ?P2 = ?Q1
+ have "{?P1} (t_wcode |+| t_utm) \<up>"
+ proof(rule_tac Hoare_plus_unhalt)
+ show "?Q1 \<mapsto> ?P2"
+ by(simp add: assert_imp_def)
next
- fix rn stp
- show " isS0 (steps (Suc 0, [Bk], Oc\<^bsup>Suc (code tp)\<^esup> @ Bk # Oc\<^bsup>Suc (bl_bin (<args>))\<^esup> @ Bk\<^bsup>rn\<^esup>) t_utm stp)
- \<Longrightarrow> False"
- using tutm_uhalt[of tp l args "Suc 0" rn] h
- apply(simp)
- apply(erule_tac x = stp in allE)
- apply(simp add: tape_of_nl_abv tape_of_nat_list.simps bin_wc_eq)
+ show "tm_wf (t_wcode, 0)" by auto
+ next
+ show "{?P1} t_wcode {?Q1}"
+ apply(rule_tac HoareI, auto)
+ using wcode_lemma_1[of args "code tp"] args
+ apply(auto)
+ apply(rule_tac x = stp in exI, simp)
done
next
- fix rn stp
- show "isS0 (steps (Suc 0, [Bk], Oc\<^bsup>Suc (code tp)\<^esup> @ Bk # Oc\<^bsup>Suc (bl_bin (<args>))\<^esup> @ Bk\<^bsup>rn\<^esup>) t_utm stp) \<Longrightarrow>
- isS0 (steps (Suc 0, [Bk], Oc\<^bsup>Suc (code tp)\<^esup> @ Bk # Oc\<^bsup>Suc (bl_bin (<args>))\<^esup> @ Bk\<^bsup>rn\<^esup>) t_utm stp)"
- by simp
- next
- show "?Q1 \<turnstile>-> ?P4"
- apply(simp add: t_imply_def)
- done
+ show "{?P2} t_utm \<up>"
+ proof(rule_tac Hoare_unhalt_I, auto)
+ fix n rn
+ assume h: "is_final (steps0 (Suc 0, [Bk], Oc \<up> Suc (code tp) @ Bk # Oc \<up> Suc (bl_bin (<args>)) @ Bk \<up> rn) t_utm n)"
+ have "\<forall> stp. \<not> is_final (steps0 (Suc 0, Bk\<up>(Suc 0), <[code tp, bl2wc (<args>)]> @ Bk\<up>(rn)) t_utm stp)"
+ using assms
+ apply(rule_tac tutm_uhalt, simp_all)
+ done
+ thus "False"
+ using h
+ apply(erule_tac x = n in allE)
+ apply(simp add: tape_of_nl_abv bin_wc_eq)
+ done
+ qed
qed
thus "?thesis"
- apply(simp add: t_imply_def UTM_pre_def)
+ apply(simp add: Hoare_unhalt_def UTM_pre_def)
done
qed
@@ -5153,11 +5296,11 @@
*}
lemma UTM_uhalt_lemma:
- "\<lbrakk>turing_basic.t_correct tp;
- \<forall> stp. (\<not> TSTD (steps (Suc 0, Bk\<^bsup>l\<^esup>, <args>) tp stp));
- args \<noteq> []\<rbrakk>
- \<Longrightarrow> \<forall> stp. \<not> isS0 (steps (Suc 0, [], <code tp # args>) UTM stp)"
-using UTM_uhalt_lemma_pre[of tp l args]
+ assumes tm_wf: "tm_wf (tp, 0)"
+ and unhalt: "\<forall> stp. (\<not> TSTD (steps0 (Suc 0, Bk\<up>(l), <args>) tp stp))"
+ and args: "args \<noteq> []"
+ shows " \<forall> stp. \<not> is_final (steps0 (Suc 0, [], <code tp # args>) UTM stp)"
+ using UTM_uhalt_lemma_pre[of tp l args] assms
apply(simp add: UTM_pre_def t_utm_def UTM_def F_aprog_def F_tprog_def)
apply(case_tac "rec_ci rec_F", simp)
done