1297 thus "?case" |
1297 thus "?case" |
1298 by(simp add: steps.simps) |
1298 by(simp add: steps.simps) |
1299 next |
1299 next |
1300 case (Suc stp st' l' r') |
1300 case (Suc stp st' l' r') |
1301 have ind: "\<And>st' l' r'. \<lbrakk>steps0 (st, l, r) ap stp = (st', l', r'); 0 < st'\<rbrakk> |
1301 have ind: "\<And>st' l' r'. \<lbrakk>steps0 (st, l, r) ap stp = (st', l', r'); 0 < st'\<rbrakk> |
1302 \<Longrightarrow> steps0 (st, l, r) (turing_basic.adjust ap) stp = (st', l', r')" by fact |
1302 \<Longrightarrow> steps0 (st, l, r) (Turing.adjust ap) stp = (st', l', r')" by fact |
1303 have h: "steps0 (st, l, r) ap (Suc stp) = (st', l', r')" by fact |
1303 have h: "steps0 (st, l, r) ap (Suc stp) = (st', l', r')" by fact |
1304 have g: "0 < st'" by fact |
1304 have g: "0 < st'" by fact |
1305 obtain st'' l'' r'' where a: "steps0 (st, l, r) ap stp = (st'', l'', r'')" |
1305 obtain st'' l'' r'' where a: "steps0 (st, l, r) ap stp = (st'', l'', r'')" |
1306 by (metis prod_cases3) |
1306 by (metis prod_cases3) |
1307 hence c:"0 < st''" |
1307 hence c:"0 < st''" |
1308 using h g |
1308 using h g |
1309 apply(simp add: step_red) |
1309 apply(simp add: step_red) |
1310 apply(case_tac st'', auto) |
1310 apply(case_tac st'', auto) |
1311 done |
1311 done |
1312 hence b: "steps0 (st, l, r) (turing_basic.adjust ap) stp = (st'', l'', r'')" |
1312 hence b: "steps0 (st, l, r) (Turing.adjust ap) stp = (st'', l'', r'')" |
1313 using a |
1313 using a |
1314 by(rule_tac ind, simp_all) |
1314 by(rule_tac ind, simp_all) |
1315 thus "?case" |
1315 thus "?case" |
1316 using assms a b h g |
1316 using assms a b h g |
1317 apply(simp add: step_red) |
1317 apply(simp add: step_red) |
3371 |
3371 |
3372 lemma [simp]: "length (mopup (Suc 0)) = 16" |
3372 lemma [simp]: "length (mopup (Suc 0)) = 16" |
3373 apply(auto simp: mopup.simps) |
3373 apply(auto simp: mopup.simps) |
3374 done |
3374 done |
3375 |
3375 |
3376 lemma [elim]: "(a, b) \<in> set (shift (turing_basic.adjust t_twice_compile) 12) \<Longrightarrow> |
3376 lemma [elim]: "(a, b) \<in> set (shift (Turing.adjust t_twice_compile) 12) \<Longrightarrow> |
3377 b \<le> (28 + (length t_twice_compile + length t_fourtimes_compile)) div 2" |
3377 b \<le> (28 + (length t_twice_compile + length t_fourtimes_compile)) div 2" |
3378 apply(simp add: t_twice_compile_def t_fourtimes_compile_def) |
3378 apply(simp add: t_twice_compile_def t_fourtimes_compile_def) |
3379 proof - |
3379 proof - |
3380 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)" |
3380 assume g: "(a, b) \<in> set (shift (Turing.adjust (tm_of abc_twice @ shift (mopup (Suc 0)) (length (tm_of abc_twice) div 2))) 12)" |
3381 moreover have "length (tm_of abc_twice) mod 2 = 0" by auto |
3381 moreover have "length (tm_of abc_twice) mod 2 = 0" by auto |
3382 moreover have "length (tm_of abc_fourtimes) mod 2 = 0" by auto |
3382 moreover have "length (tm_of abc_fourtimes) mod 2 = 0" by auto |
3383 ultimately have "list_all (\<lambda>(acn, st). (st \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2)) |
3383 ultimately have "list_all (\<lambda>(acn, st). (st \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2)) |
3384 (shift (turing_basic.adjust t_twice_compile) 12)" |
3384 (shift (Turing.adjust t_twice_compile) 12)" |
3385 proof(auto simp: mod_ex1) |
3385 proof(auto simp: mod_ex1) |
3386 fix q qa |
3386 fix q qa |
3387 assume h: "length (tm_of abc_twice) = 2 * q" "length (tm_of abc_fourtimes) = 2 * qa" |
3387 assume h: "length (tm_of abc_twice) = 2 * q" "length (tm_of abc_fourtimes) = 2 * qa" |
3388 hence "list_all (\<lambda>(acn, st). st \<le> (18 + (q + qa)) + 12) (shift (turing_basic.adjust t_twice_compile) 12)" |
3388 hence "list_all (\<lambda>(acn, st). st \<le> (18 + (q + qa)) + 12) (shift (Turing.adjust t_twice_compile) 12)" |
3389 proof(rule_tac tm_wf_shift t_twice_compile_def) |
3389 proof(rule_tac tm_wf_shift t_twice_compile_def) |
3390 have "list_all (\<lambda>(acn, st). st \<le> Suc (length t_twice_compile div 2)) (adjust t_twice_compile)" |
3390 have "list_all (\<lambda>(acn, st). st \<le> Suc (length t_twice_compile div 2)) (adjust t_twice_compile)" |
3391 by(rule_tac tm_wf_change_termi, auto) |
3391 by(rule_tac tm_wf_change_termi, auto) |
3392 thus "list_all (\<lambda>(acn, st). st \<le> 18 + (q + qa)) (turing_basic.adjust t_twice_compile)" |
3392 thus "list_all (\<lambda>(acn, st). st \<le> 18 + (q + qa)) (Turing.adjust t_twice_compile)" |
3393 using h |
3393 using h |
3394 apply(simp add: t_twice_compile_def, auto simp: List.list_all_length) |
3394 apply(simp add: t_twice_compile_def, auto simp: List.list_all_length) |
3395 done |
3395 done |
3396 qed |
3396 qed |
3397 thus "list_all (\<lambda>(acn, st). st \<le> 30 + (q + qa)) (shift (turing_basic.adjust t_twice_compile) 12)" |
3397 thus "list_all (\<lambda>(acn, st). st \<le> 30 + (q + qa)) (shift (Turing.adjust t_twice_compile) 12)" |
3398 by simp |
3398 by simp |
3399 qed |
3399 qed |
3400 thus "b \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2" |
3400 thus "b \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2" |
3401 using g |
3401 using g |
3402 apply(auto simp:t_twice_compile_def) |
3402 apply(auto simp:t_twice_compile_def) |
3403 apply(simp add: Ball_set[THEN sym]) |
3403 apply(simp add: Ball_set[THEN sym]) |
3404 apply(erule_tac x = "(a, b)" in ballE, simp, simp) |
3404 apply(erule_tac x = "(a, b)" in ballE, simp, simp) |
3405 done |
3405 done |
3406 qed |
3406 qed |
3407 |
3407 |
3408 lemma [elim]: "(a, b) \<in> set (shift (turing_basic.adjust t_fourtimes_compile) (t_twice_len + 13)) |
3408 lemma [elim]: "(a, b) \<in> set (shift (Turing.adjust t_fourtimes_compile) (t_twice_len + 13)) |
3409 \<Longrightarrow> b \<le> (28 + (length t_twice_compile + length t_fourtimes_compile)) div 2" |
3409 \<Longrightarrow> b \<le> (28 + (length t_twice_compile + length t_fourtimes_compile)) div 2" |
3410 apply(simp add: t_twice_compile_def t_fourtimes_compile_def t_twice_len_def) |
3410 apply(simp add: t_twice_compile_def t_fourtimes_compile_def t_twice_len_def) |
3411 proof - |
3411 proof - |
3412 assume g: "(a, b) \<in> set (shift (turing_basic.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) |
3412 assume g: "(a, b) \<in> set (shift (Turing.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) |
3413 (length (tm_of abc_fourtimes) div 2))) (length t_twice div 2 + 13))" |
3413 (length (tm_of abc_fourtimes) div 2))) (length t_twice div 2 + 13))" |
3414 moreover have "length (tm_of abc_twice) mod 2 = 0" by auto |
3414 moreover have "length (tm_of abc_twice) mod 2 = 0" by auto |
3415 moreover have "length (tm_of abc_fourtimes) mod 2 = 0" by auto |
3415 moreover have "length (tm_of abc_fourtimes) mod 2 = 0" by auto |
3416 ultimately have "list_all (\<lambda>(acn, st). (st \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2)) |
3416 ultimately have "list_all (\<lambda>(acn, st). (st \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2)) |
3417 (shift (turing_basic.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) |
3417 (shift (Turing.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) |
3418 (length (tm_of abc_fourtimes) div 2))) (length t_twice div 2 + 13))" |
3418 (length (tm_of abc_fourtimes) div 2))) (length t_twice div 2 + 13))" |
3419 proof(auto simp: mod_ex1 t_twice_def t_twice_compile_def) |
3419 proof(auto simp: mod_ex1 t_twice_def t_twice_compile_def) |
3420 fix q qa |
3420 fix q qa |
3421 assume h: "length (tm_of abc_twice) = 2 * q" "length (tm_of abc_fourtimes) = 2 * qa" |
3421 assume h: "length (tm_of abc_twice) = 2 * q" "length (tm_of abc_fourtimes) = 2 * qa" |
3422 hence "list_all (\<lambda>(acn, st). st \<le> (9 + qa + (21 + q))) |
3422 hence "list_all (\<lambda>(acn, st). st \<le> (9 + qa + (21 + q))) |
3423 (shift (turing_basic.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa)) (21 + q))" |
3423 (shift (Turing.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa)) (21 + q))" |
3424 proof(rule_tac tm_wf_shift t_twice_compile_def) |
3424 proof(rule_tac tm_wf_shift t_twice_compile_def) |
3425 have "list_all (\<lambda>(acn, st). st \<le> Suc (length (tm_of abc_fourtimes @ shift |
3425 have "list_all (\<lambda>(acn, st). st \<le> Suc (length (tm_of abc_fourtimes @ shift |
3426 (mopup (Suc 0)) qa) div 2)) (adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa))" |
3426 (mopup (Suc 0)) qa) div 2)) (adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa))" |
3427 apply(rule_tac tm_wf_change_termi) |
3427 apply(rule_tac tm_wf_change_termi) |
3428 using wf_fourtimes h |
3428 using wf_fourtimes h |
3429 apply(simp add: t_fourtimes_compile_def) |
3429 apply(simp add: t_fourtimes_compile_def) |
3430 done |
3430 done |
3431 thus "list_all (\<lambda>(acn, st). st \<le> 9 + qa) ((turing_basic.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa)))" |
3431 thus "list_all (\<lambda>(acn, st). st \<le> 9 + qa) ((Turing.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa)))" |
3432 using h |
3432 using h |
3433 apply(simp) |
3433 apply(simp) |
3434 done |
3434 done |
3435 qed |
3435 qed |
3436 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))" |
3436 thus "list_all (\<lambda>(acn, st). st \<le> 30 + (q + qa)) (shift (Turing.adjust (tm_of abc_fourtimes @ shift (mopup (Suc 0)) qa)) (21 + q))" |
3437 apply(subgoal_tac "qa + q = q + qa") |
3437 apply(subgoal_tac "qa + q = q + qa") |
3438 apply(simp, simp) |
3438 apply(simp, simp) |
3439 done |
3439 done |
3440 qed |
3440 qed |
3441 thus "b \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2" |
3441 thus "b \<le> (60 + (length (tm_of abc_twice) + length (tm_of abc_fourtimes))) div 2" |
4699 done |
4699 done |
4700 |
4700 |
4701 declare tape_of_nl_abv_cons[simp del] |
4701 declare tape_of_nl_abv_cons[simp del] |
4702 |
4702 |
4703 lemma t_utm_halt_eq': |
4703 lemma t_utm_halt_eq': |
4704 "\<lbrakk>turing_basic.t_correct tp; |
4704 "\<lbrakk>Turing.t_correct tp; |
4705 0 < rs; |
4705 0 < rs; |
4706 steps (Suc 0, Bk\<up>(l), <lm::nat list>) tp stp = (0, Bk\<up>(m), Oc\<up>(rs)@Bk\<up>(n))\<rbrakk> |
4706 steps (Suc 0, Bk\<up>(l), <lm::nat list>) tp stp = (0, Bk\<up>(m), Oc\<up>(rs)@Bk\<up>(n))\<rbrakk> |
4707 \<Longrightarrow> \<exists>stp m n. steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp = |
4707 \<Longrightarrow> \<exists>stp m n. steps (Suc 0, [Bk, Bk], <[code tp, bl2wc (<lm>)]>) t_utm stp = |
4708 (0, Bk\<up>(m), Oc\<up>(rs) @ Bk\<up>(n))" |
4708 (0, Bk\<up>(m), Oc\<up>(rs) @ Bk\<up>(n))" |
4709 apply(drule_tac l = l in F_abc_halt_eq, simp, simp, simp) |
4709 apply(drule_tac l = l in F_abc_halt_eq, simp, simp, simp) |