449 apply(case_tac tps, simp, simp, simp) |
449 apply(case_tac tps, simp, simp, simp) |
450 apply(subgoal_tac "concat (take n tps) @ (tps ! n) = |
450 apply(subgoal_tac "concat (take n tps) @ (tps ! n) = |
451 concat (take (Suc n) tps)") |
451 concat (take (Suc n) tps)") |
452 apply(simp only: append_assoc[THEN sym], simp only: append_assoc) |
452 apply(simp only: append_assoc[THEN sym], simp only: append_assoc) |
453 apply(subgoal_tac " concat (drop (Suc n) tps) = tps ! Suc n @ |
453 apply(subgoal_tac " concat (drop (Suc n) tps) = tps ! Suc n @ |
454 concat (drop (Suc (Suc n)) tps)", simp) |
454 concat (drop (Suc (Suc n)) tps)") |
455 apply(rule_tac concat_drop_suc_iff, simp) |
455 apply (metis append_take_drop_id concat_append) |
456 apply(rule_tac concat_take_suc_iff, simp) |
456 apply(rule concat_drop_suc_iff,force) |
457 done |
457 by (simp add: concat_suc) |
458 |
458 |
459 declare append_assoc[simp] |
459 declare append_assoc[simp] |
460 |
460 |
461 lemma map_of: "n < length xs \<Longrightarrow> (map f xs) ! n = f (xs ! n)" |
461 lemma map_of: "n < length xs \<Longrightarrow> (map f xs) ! n = f (xs ! n)" |
462 by(auto) |
462 by(auto) |
496 apply(case_tac as, auto simp: start_of.simps) |
496 apply(case_tac as, auto simp: start_of.simps) |
497 done |
497 done |
498 |
498 |
499 lemma div_apart: "\<lbrakk>x mod (2::nat) = 0; y mod 2 = 0\<rbrakk> |
499 lemma div_apart: "\<lbrakk>x mod (2::nat) = 0; y mod 2 = 0\<rbrakk> |
500 \<Longrightarrow> (x + y) div 2 = x div 2 + y div 2" |
500 \<Longrightarrow> (x + y) div 2 = x div 2 + y div 2" |
501 apply(drule mod_eqD)+ |
501 by(auto) |
502 apply(auto) |
|
503 done |
|
504 |
502 |
505 lemma div_apart_iff: "\<lbrakk>x mod (2::nat) = 0; y mod 2 = 0\<rbrakk> \<Longrightarrow> |
503 lemma div_apart_iff: "\<lbrakk>x mod (2::nat) = 0; y mod 2 = 0\<rbrakk> \<Longrightarrow> |
506 (x + y) mod 2 = 0" |
504 (x + y) mod 2 = 0" |
507 apply(auto) |
505 by(auto) |
508 done |
|
509 |
506 |
510 lemma [simp]: "length (layout_of aprog) = length aprog" |
507 lemma [simp]: "length (layout_of aprog) = length aprog" |
511 apply(auto simp: layout_of.simps) |
508 by(auto simp: layout_of.simps) |
512 done |
|
513 |
509 |
514 lemma start_of_ind: "\<lbrakk>as < length aprog; ly = layout_of aprog\<rbrakk> \<Longrightarrow> |
510 lemma start_of_ind: "\<lbrakk>as < length aprog; ly = layout_of aprog\<rbrakk> \<Longrightarrow> |
515 start_of ly (Suc as) = start_of ly as + |
511 start_of ly (Suc as) = start_of ly as + |
516 length ((tms_of aprog) ! as) div 2" |
512 length ((tms_of aprog) ! as) div 2" |
517 apply(simp only: start_of.simps, simp) |
513 by (auto simp: start_of.simps tms_of.simps layout_of.simps |
518 apply(auto simp: start_of.simps tms_of.simps layout_of.simps |
514 tpairs_of.simps ci_length take_Suc take_Suc_conv_app_nth) |
519 tpairs_of.simps) |
|
520 apply(simp add: ci_length take_Suc take_Suc_conv_app_nth) |
|
521 done |
|
522 |
515 |
523 lemma concat_take_suc: "Suc n \<le> length xs \<Longrightarrow> |
516 lemma concat_take_suc: "Suc n \<le> length xs \<Longrightarrow> |
524 concat (take (Suc n) xs) = concat (take n xs) @ (xs ! n)" |
517 concat (take (Suc n) xs) = concat (take n xs) @ (xs ! n)" |
525 apply(subgoal_tac "take (Suc n) xs = |
518 using concat_suc. |
526 take n xs @ [xs ! n]") |
|
527 apply(auto) |
|
528 done |
|
529 |
519 |
530 lemma [simp]: |
520 lemma [simp]: |
531 "\<lbrakk>as < length aprog; (abc_fetch as aprog) = Some ins\<rbrakk> |
521 "\<lbrakk>as < length aprog; (abc_fetch as aprog) = Some ins\<rbrakk> |
532 \<Longrightarrow> ci (layout_of aprog) |
522 \<Longrightarrow> ci (layout_of aprog) |
533 (start_of (layout_of aprog) as) (ins) \<in> set (tms_of aprog)" |
523 (start_of (layout_of aprog) as) (ins) \<in> set (tms_of aprog)" |
534 apply(insert ci_nth[of "layout_of aprog" aprog as], simp) |
524 by(insert ci_nth[of "layout_of aprog" aprog as], simp) |
535 done |
|
536 |
525 |
537 lemma [simp]: "length (tms_of ap) = length ap" |
526 lemma [simp]: "length (tms_of ap) = length ap" |
538 by(auto simp: tms_of.simps tpairs_of.simps) |
527 by(auto simp: tms_of.simps tpairs_of.simps) |
539 |
528 |
540 lemma [intro]: "n < length ap \<Longrightarrow> length (tms_of ap ! n) mod 2 = 0" |
529 lemma [intro]: "n < length ap \<Longrightarrow> length (tms_of ap ! n) mod 2 = 0" |
541 apply(auto simp: tms_of.simps tpairs_of.simps) |
530 apply(cases "ap ! n") |
542 apply(case_tac "ap ! n", auto simp: ci.simps length_findnth tinc_b_def tdec_b_def) |
531 by (auto simp: tms_of.simps tpairs_of.simps ci.simps length_findnth tinc_b_def tdec_b_def) |
543 apply arith |
|
544 by arith |
|
545 |
532 |
546 lemma compile_mod2: "length (concat (take n (tms_of ap))) mod 2 = 0" |
533 lemma compile_mod2: "length (concat (take n (tms_of ap))) mod 2 = 0" |
547 apply(induct n, auto) |
534 proof(induct n) |
548 apply(case_tac "n < length (tms_of ap)", simp add: take_Suc_conv_app_nth, auto) |
535 case 0 |
549 (*apply(subgoal_tac "length (tms_of ap ! n) mod 2 = 0") |
536 then show ?case by (auto simp add: take_Suc_conv_app_nth) |
550 apply arith |
537 next |
551 by auto |
538 case (Suc n) |
552 *) |
539 hence "n < length (tms_of ap) \<Longrightarrow> is_even (length (concat (take (Suc n) (tms_of ap))))" |
553 done |
540 unfolding take_Suc_conv_app_nth by fastforce |
|
541 with Suc show ?case by(cases "n < length (tms_of ap)", auto) |
|
542 qed |
554 |
543 |
555 lemma tpa_states: |
544 lemma tpa_states: |
556 "\<lbrakk>tp = concat (take as (tms_of ap)); |
545 "\<lbrakk>tp = concat (take as (tms_of ap)); |
557 as \<le> length ap\<rbrakk> \<Longrightarrow> |
546 as \<le> length ap\<rbrakk> \<Longrightarrow> |
558 start_of (layout_of ap) as = Suc (length tp div 2)" |
547 start_of (layout_of ap) as = Suc (length tp div 2)" |
613 by(rule_tac t_split, simp_all) |
602 by(rule_tac t_split, simp_all) |
614 then obtain tp1 tp2 where a: "concat (tms_of ap) = tp1 @ ci ly (start_of ly as) ins @ tp2 \<and> |
603 then obtain tp1 tp2 where a: "concat (tms_of ap) = tp1 @ ci ly (start_of ly as) ins @ tp2 \<and> |
615 tp1 = concat (take as (tms_of ap)) \<and> tp2 = concat (drop (Suc as) (tms_of ap))" by blast |
604 tp1 = concat (take as (tms_of ap)) \<and> tp2 = concat (drop (Suc as) (tms_of ap))" by blast |
616 then have b: "start_of (layout_of ap) as = Suc (length tp1 div 2)" |
605 then have b: "start_of (layout_of ap) as = Suc (length tp1 div 2)" |
617 using fetch |
606 using fetch |
618 apply(rule_tac tpa_states, simp, simp add: abc_fetch.simps split: if_splits) |
607 by(rule_tac tpa_states, simp, simp add: abc_fetch.simps split: if_splits) |
619 done |
|
620 have "fetch (tp1 @ (ci ly (start_of ly as) ins) @ tp2) s b = |
608 have "fetch (tp1 @ (ci ly (start_of ly as) ins) @ tp2) s b = |
621 fetch (ci ly (start_of ly as) ins) (s - length tp1 div 2) b" |
609 fetch (ci ly (start_of ly as) ins) (s - length tp1 div 2) b" |
622 proof(rule_tac append_append_fetch) |
610 proof(rule_tac append_append_fetch) |
623 show "length tp1 mod 2 = 0" |
611 show "length tp1 mod 2 = 0" |
624 using a |
612 using a |
625 by(auto, rule_tac compile_mod2) |
613 by(auto, rule_tac compile_mod2) |
626 next |
614 next |
627 show "length (ci ly (start_of ly as) ins) mod 2 = 0" |
615 show "length (ci ly (start_of ly as) ins) mod 2 = 0" |
628 apply(case_tac ins, auto simp: ci.simps length_findnth tinc_b_def tdec_b_def) |
616 by(case_tac ins, auto simp: ci.simps length_findnth tinc_b_def tdec_b_def) |
629 by(arith, arith) |
|
630 next |
617 next |
631 show "length tp1 div 2 < s \<and> s \<le> |
618 show "length tp1 div 2 < s \<and> s \<le> |
632 length tp1 div 2 + length (ci ly (start_of ly as) ins) div 2" |
619 length tp1 div 2 + length (ci ly (start_of ly as) ins) div 2" |
633 proof - |
620 proof - |
634 have "length (ci ly (start_of ly as) ins) div 2 = length_of ins" |
621 have "length (ci ly (start_of ly as) ins) div 2 = length_of ins" |
692 done |
679 done |
693 from this and h have "fetch (ci ly (start_of ly as) ins) (Suc s - start_of ly as) b = (Nop, 0)" |
680 from this and h have "fetch (ci ly (start_of ly as) ins) (Suc s - start_of ly as) b = (Nop, 0)" |
694 using abc_fetch layout |
681 using abc_fetch layout |
695 apply(case_tac b, simp_all add: Suc_diff_le) |
682 apply(case_tac b, simp_all add: Suc_diff_le) |
696 apply(case_tac [!] ins, simp_all add: start_of_Suc2 start_of_Suc1 start_of_Suc3) |
683 apply(case_tac [!] ins, simp_all add: start_of_Suc2 start_of_Suc1 start_of_Suc3) |
697 apply(simp_all only: length_ci_inc length_ci_dec length_ci_goto, auto) |
684 by (simp_all only: length_ci_inc length_ci_dec length_ci_goto, auto) |
698 using layout |
|
699 apply(subgoal_tac [!] "start_of ly (Suc as) = start_of ly as + 2*nat1 + 16", simp_all) |
|
700 apply(rule_tac [!] start_of_Suc2, auto) |
|
701 done |
|
702 from fetch and notfinal this show "?thesis"by simp |
685 from fetch and notfinal this show "?thesis"by simp |
703 qed |
686 qed |
704 ultimately show "?thesis" |
687 ultimately show "?thesis" |
705 using assms |
688 using assms |
706 apply(drule_tac b= b and ins = ins in step_eq_fetch', auto) |
689 by(drule_tac b= b and ins = ins in step_eq_fetch', auto) |
707 done |
|
708 qed |
690 qed |
709 |
691 |
710 |
692 |
711 lemma step_eq_in: |
693 lemma step_eq_in: |
712 assumes layout: "ly = layout_of ap" |
694 assumes layout: "ly = layout_of ap" |
1262 (if lm1 = [] then aaa = Bk # Bk # ires else aaa = [Bk] @ <rev lm1> @ Bk # Bk # ires) \<and> |
1243 (if lm1 = [] then aaa = Bk # Bk # ires else aaa = [Bk] @ <rev lm1> @ Bk # Bk # ires) \<and> |
1263 Oc # xs = [Oc] @ Bk\<up>rn" |
1244 Oc # xs = [Oc] @ Bk\<up>rn" |
1264 (is "\<exists>lm1 tn rn. ?P lm1 tn rn") |
1245 (is "\<exists>lm1 tn rn. ?P lm1 tn rn") |
1265 proof - |
1246 proof - |
1266 from h1 and h2 have "?P lm1 0 (rn - 1)" |
1247 from h1 and h2 have "?P lm1 0 (rn - 1)" |
1267 apply(auto simp: Oc_def |
1248 apply(auto simp:tape_of_nat_def) |
1268 tape_of_nl_abv tape_of_nat_list.simps) |
|
1269 by(case_tac "rn::nat", simp, simp) |
1249 by(case_tac "rn::nat", simp, simp) |
1270 thus ?thesis by blast |
1250 thus ?thesis by blast |
1271 qed |
1251 qed |
1272 qed |
1252 qed |
1273 |
1253 |
1274 lemma [simp]: "inv_locate_a (as, am) (q, aaa, []) ires \<Longrightarrow> |
1254 lemma inv_locate_a[simp]: "inv_locate_a (as, am) (q, aaa, []) ires \<Longrightarrow> |
1275 inv_locate_a (as, am) (q, aaa, [Oc]) ires" |
1255 inv_locate_a (as, am) (q, aaa, [Oc]) ires" |
1276 apply(insert locate_a_2_locate_a [of as am q aaa "[]"]) |
1256 apply(insert locate_a_2_locate_a [of as am q aaa "[]"]) |
1277 apply(subgoal_tac "inv_locate_a (as, am) (q, aaa, [Bk]) ires", auto) |
1257 apply(subgoal_tac "inv_locate_a (as, am) (q, aaa, [Bk]) ires", auto) |
1278 done |
1258 done |
1279 |
1259 |
1280 (*inv: from locate_b to locate_b*) |
1260 (*inv: from locate_b to locate_b*) |
1281 lemma [simp]: "inv_locate_b (as, am) (q, aaa, Oc # xs) ires |
1261 lemma inv_locate_b[simp]: "inv_locate_b (as, am) (q, aaa, Oc # xs) ires |
1282 \<Longrightarrow> inv_locate_b (as, am) (q, Oc # aaa, xs) ires" |
1262 \<Longrightarrow> inv_locate_b (as, am) (q, Oc # aaa, xs) ires" |
1283 apply(simp only: inv_locate_b.simps in_middle.simps) |
1263 apply(simp only: inv_locate_b.simps in_middle.simps) |
1284 apply(erule exE)+ |
1264 apply(erule exE)+ |
1285 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
1265 apply(rule_tac x = lm1 in exI, rule_tac x = lm2 in exI, |
1286 rule_tac x = tn in exI, rule_tac x = m in exI) |
1266 rule_tac x = tn in exI, rule_tac x = m in exI) |
1287 apply(rule_tac x = "Suc ml" in exI, rule_tac x = "mr - 1" in exI, |
1267 apply(rule_tac x = "Suc ml" in exI, rule_tac x = "mr - 1" in exI, |
1288 rule_tac x = rn in exI) |
1268 rule_tac x = rn in exI) |
1289 apply(case_tac mr, simp_all, auto) |
1269 apply(case_tac mr, simp_all, auto) |
1290 done |
1270 done |
1291 |
1271 |
1292 lemma [simp]: "<[x::nat]> = Oc\<up>(Suc x)" |
1272 lemma tape_nat[simp]: "<[x::nat]> = Oc\<up>(Suc x)" |
1293 apply(simp add: tape_of_nat_abv tape_of_nl_abv) |
1273 apply(simp add: tape_of_nat_def tape_of_list_def) |
1294 done |
1274 done |
1295 |
1275 |
1296 lemma [simp]: " <([]::nat list)> = []" |
1276 lemma tape_empty_list[simp]: " <([]::nat list)> = []" |
1297 apply(simp add: tape_of_nl_abv) |
1277 apply(simp add: tape_of_list_def) |
1298 done |
1278 done |
1299 |
1279 |
1300 lemma [simp]: "\<lbrakk>inv_locate_b (as, am) (q, aaa, Bk # xs) ires; \<exists>n. xs = Bk\<up>n\<rbrakk> |
1280 lemma inv_locate[simp]: "\<lbrakk>inv_locate_b (as, am) (q, aaa, Bk # xs) ires; \<exists>n. xs = Bk\<up>n\<rbrakk> |
1301 \<Longrightarrow> inv_locate_a (as, am) (Suc q, Bk # aaa, xs) ires" |
1281 \<Longrightarrow> inv_locate_a (as, am) (Suc q, Bk # aaa, xs) ires" |
1302 apply(simp add: inv_locate_b.simps inv_locate_a.simps) |
1282 apply(simp add: inv_locate_b.simps inv_locate_a.simps) |
1303 apply(rule_tac disjI2, rule_tac disjI1) |
1283 apply(rule_tac disjI2, rule_tac disjI1) |
1304 apply(simp only: in_middle.simps at_begin_fst_bwtn.simps) |
1284 apply(simp only: in_middle.simps at_begin_fst_bwtn.simps) |
1305 apply(erule_tac exE)+ |
1285 apply(erule_tac exE)+ |
1626 apply(rule_tac x = rn in exI, rule_tac x = "Suc m" in exI, |
1606 apply(rule_tac x = rn in exI, rule_tac x = "Suc m" in exI, |
1627 rule_tac x = "lm1" in exI, simp) |
1607 rule_tac x = "lm1" in exI, simp) |
1628 apply(rule_tac x = "lm2" in exI, simp) |
1608 apply(rule_tac x = "lm2" in exI, simp) |
1629 apply(simp only: Suc_diff_le exp_ind) |
1609 apply(simp only: Suc_diff_le exp_ind) |
1630 apply(subgoal_tac "lm2 = []", simp) |
1610 apply(subgoal_tac "lm2 = []", simp) |
1631 apply(drule_tac length_equal, simp) |
1611 apply(drule_tac length_equal, simp) |
1632 done |
1612 by (metis (no_types, lifting) add_diff_inverse_nat append.assoc append_eq_append_conv length_append length_replicate list.inject) |
1633 |
1613 |
1634 lemma [simp]: "inv_locate_b (as, am) (n, aaa, []) ires \<Longrightarrow> |
1614 lemma [simp]: "inv_locate_b (as, am) (n, aaa, []) ires \<Longrightarrow> |
1635 inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n))) |
1615 inv_after_write (as, abc_lm_s am n (Suc (abc_lm_v am n))) |
1636 (s, aaa, [Oc]) ires" |
1616 (s, aaa, [Oc]) ires" |
1637 apply(insert inv_locate_b_2_after_write [of as am n aaa "[]"]) |
1617 apply(insert inv_locate_b_2_after_write [of as am n aaa "[]"]) |
1817 apply(simp add: inv_on_left_moving.simps) |
1797 apply(simp add: inv_on_left_moving.simps) |
1818 apply(case_tac "l \<noteq> []", rule conjI, simp, simp) |
1798 apply(case_tac "l \<noteq> []", rule conjI, simp, simp) |
1819 apply(case_tac "hd l", simp, simp, simp) |
1799 apply(case_tac "hd l", simp, simp, simp) |
1820 done |
1800 done |
1821 |
1801 |
1822 (*inv: from on_left_moving to check_left_moving*) |
1802 lemma from_on_left_moving_to_check_left_moving[simp]: "inv_on_left_moving_in_middle_B (as, lm) |
1823 lemma [simp]: "inv_on_left_moving_in_middle_B (as, lm) |
|
1824 (s, Bk # list, Bk # r) ires |
1803 (s, Bk # list, Bk # r) ires |
1825 \<Longrightarrow> inv_check_left_moving_on_leftmost (as, lm) |
1804 \<Longrightarrow> inv_check_left_moving_on_leftmost (as, lm) |
1826 (s', list, Bk # Bk # r) ires" |
1805 (s', list, Bk # Bk # r) ires" |
1827 apply(auto simp: inv_on_left_moving_in_middle_B.simps |
1806 apply(auto simp: inv_on_left_moving_in_middle_B.simps |
1828 inv_check_left_moving_on_leftmost.simps split: if_splits) |
1807 inv_check_left_moving_on_leftmost.simps split: if_splits) |
1829 apply(case_tac [!] "rev lm1", simp_all) |
1808 apply(case_tac [!] "rev lm1", simp_all) |
1830 apply(case_tac [!] lista, simp_all add: tape_of_nl_abv tape_of_nat_abv tape_of_nat_list.simps) |
1809 apply(case_tac [!] lista, simp_all add: tape_of_nat_def tape_of_list_def) |
1831 done |
1810 done |
1832 |
1811 |
1833 lemma [simp]: |
1812 lemma [simp]: |
1834 "inv_check_left_moving_in_middle (as, lm) (s, l, Bk # r) ires= False" |
1813 "inv_check_left_moving_in_middle (as, lm) (s, l, Bk # r) ires= False" |
1835 by(auto simp: inv_check_left_moving_in_middle.simps ) |
1814 by(auto simp: inv_check_left_moving_in_middle.simps ) |
1893 apply(simp only: inv_check_left_moving_in_middle.simps |
1872 apply(simp only: inv_check_left_moving_in_middle.simps |
1894 inv_on_left_moving_in_middle_B.simps) |
1873 inv_on_left_moving_in_middle_B.simps) |
1895 apply(erule_tac exE)+ |
1874 apply(erule_tac exE)+ |
1896 apply(rule_tac x = "rev (tl (rev lm1))" in exI, |
1875 apply(rule_tac x = "rev (tl (rev lm1))" in exI, |
1897 rule_tac x = "[hd (rev lm1)] @ lm2" in exI, auto) |
1876 rule_tac x = "[hd (rev lm1)] @ lm2" in exI, auto) |
1898 apply(case_tac [!] "rev lm1",simp_all add: tape_of_nat_abv tape_of_nl_abv tape_of_nat_list.simps) |
1877 apply(case_tac [!] "rev lm1",simp_all add: tape_of_nat_def tape_of_list_def tape_of_nat_list.simps) |
1899 apply(case_tac [!] a, simp_all) |
1878 apply(case_tac [!] a, simp_all) |
1900 apply(case_tac [1] lm2, simp_all add: tape_of_nat_list.simps tape_of_nat_abv, auto) |
1879 apply(case_tac [1] lm2, auto simp:tape_of_nat_def) |
1901 apply(case_tac [3] lm2, simp_all add: tape_of_nat_list.simps tape_of_nat_abv, auto) |
1880 apply(case_tac [3] lm2, auto simp:tape_of_nat_def) |
1902 apply(case_tac [!] lista, simp_all add: tape_of_nat_abv tape_of_nat_list.simps) |
1881 apply(case_tac [!] lista, simp_all add: tape_of_nat_def) |
1903 done |
1882 done |
1904 |
1883 |
1905 lemma [simp]: |
1884 lemma [simp]: |
1906 "inv_check_left_moving_in_middle (as, lm) (s, [], Oc # r) ires\<Longrightarrow> |
1885 "inv_check_left_moving_in_middle (as, lm) (s, [], Oc # r) ires\<Longrightarrow> |
1907 inv_check_left_moving_in_middle (as, lm) (s', [Bk], Oc # r) ires" |
1886 inv_check_left_moving_in_middle (as, lm) (s', [Bk], Oc # r) ires" |
3484 (start_of (layout_of ap) as + 2 * n + 16, a, b) ires; |
3463 (start_of (layout_of ap) as + 2 * n + 16, a, b) ires; |
3485 abc_lm_v lm n > 0; |
3464 abc_lm_v lm n > 0; |
3486 abc_fetch as ap = Some (Dec n e)\<rbrakk> |
3465 abc_fetch as ap = Some (Dec n e)\<rbrakk> |
3487 \<Longrightarrow> crsp (layout_of ap) (abc_step_l (as, lm) (Some (Dec n e))) |
3466 \<Longrightarrow> crsp (layout_of ap) (abc_step_l (as, lm) (Some (Dec n e))) |
3488 (start_of (layout_of ap) as + 2 * n + 16, a, b) ires" |
3467 (start_of (layout_of ap) as + 2 * n + 16, a, b) ires" |
3489 apply(auto simp: inv_stop.simps crsp.simps abc_step_l.simps startof_Suc2) |
3468 by(auto simp: inv_stop.simps crsp.simps abc_step_l.simps startof_Suc2) |
3490 apply(drule_tac startof_Suc2, simp) |
|
3491 done |
|
3492 |
3469 |
3493 lemma crsp_step_dec_b_suc: |
3470 lemma crsp_step_dec_b_suc: |
3494 assumes layout: "ly = layout_of ap" |
3471 assumes layout: "ly = layout_of ap" |
3495 and crsp: "crsp ly (as, lm) (s, l, r) ires" |
3472 and crsp: "crsp ly (as, lm) (s, l, r) ires" |
3496 and inv_start: "inv_locate_a (as, lm) (n, la, ra) ires" |
3473 and inv_start: "inv_locate_a (as, lm) (n, la, ra) ires" |
3691 apply(case_tac b, auto simp: ci.simps adjust.simps) |
3668 apply(case_tac b, auto simp: ci.simps adjust.simps) |
3692 done |
3669 done |
3693 |
3670 |
3694 lemma length_tp'[simp]: |
3671 lemma length_tp'[simp]: |
3695 "\<lbrakk>ly = layout_of ap; tp = tm_of ap\<rbrakk> \<Longrightarrow> |
3672 "\<lbrakk>ly = layout_of ap; tp = tm_of ap\<rbrakk> \<Longrightarrow> |
3696 length tp = 2 * listsum (take (length ap) (layout_of ap))" |
3673 length tp = 2 * sum_list (take (length ap) (layout_of ap))" |
3697 proof(induct ap arbitrary: ly tp rule: rev_induct) |
3674 proof(induct ap arbitrary: ly tp rule: rev_induct) |
3698 case Nil |
3675 case Nil |
3699 thus "?case" |
3676 thus "?case" |
3700 by(simp add: tms_of.simps tm_of.simps tpairs_of.simps) |
3677 by(simp add: tms_of.simps tm_of.simps tpairs_of.simps) |
3701 next |
3678 next |
3702 fix x xs ly tp |
3679 fix x xs ly tp |
3703 assume ind: "\<And>ly tp. \<lbrakk>ly = layout_of xs; tp = tm_of xs\<rbrakk> \<Longrightarrow> |
3680 assume ind: "\<And>ly tp. \<lbrakk>ly = layout_of xs; tp = tm_of xs\<rbrakk> \<Longrightarrow> |
3704 length tp = 2 * listsum (take (length xs) (layout_of xs))" |
3681 length tp = 2 * sum_list (take (length xs) (layout_of xs))" |
3705 and layout: "ly = layout_of (xs @ [x])" |
3682 and layout: "ly = layout_of (xs @ [x])" |
3706 and tp: "tp = tm_of (xs @ [x])" |
3683 and tp: "tp = tm_of (xs @ [x])" |
3707 obtain ly' where a: "ly' = layout_of xs" |
3684 obtain ly' where a: "ly' = layout_of xs" |
3708 by metis |
3685 by metis |
3709 obtain tp' where b: "tp' = tm_of xs" |
3686 obtain tp' where b: "tp' = tm_of xs" |
3710 by metis |
3687 by metis |
3711 have c: "length tp' = 2 * listsum (take (length xs) (layout_of xs))" |
3688 have c: "length tp' = 2 * sum_list (take (length xs) (layout_of xs))" |
3712 using a b |
3689 using a b |
3713 by(erule_tac ind, simp) |
3690 by(erule_tac ind, simp) |
3714 thus "length tp = 2 * |
3691 thus "length tp = 2 * |
3715 listsum (take (length (xs @ [x])) (layout_of (xs @ [x])))" |
3692 sum_list (take (length (xs @ [x])) (layout_of (xs @ [x])))" |
3716 using tp b |
3693 using tp b |
3717 apply(auto simp: layout_id_cons tm_of.simps tms_of.simps length_concat tpairs_id_cons map_length_ci) |
3694 apply(auto simp: layout_id_cons tm_of.simps tms_of.simps length_concat tpairs_id_cons map_length_ci) |
3718 apply(case_tac x) |
3695 apply(case_tac x) |
3719 apply(auto simp: ci.simps tinc_b_def tdec_b_def length_findnth adjust.simps length_of.simps |
3696 apply(auto simp: ci.simps tinc_b_def tdec_b_def length_findnth adjust.simps length_of.simps |
3720 split: abc_inst.splits) |
3697 split: abc_inst.splits) |