168 lemma wf_additon_LE[simp]: "wf addition_LE" |
168 lemma wf_additon_LE[simp]: "wf addition_LE" |
169 by(auto simp: addition_LE_def lex_triple_def lex_pair_def) |
169 by(auto simp: addition_LE_def lex_triple_def lex_pair_def) |
170 |
170 |
171 declare addition_inv.simps[simp del] |
171 declare addition_inv.simps[simp del] |
172 |
172 |
|
173 lemma update_zero_to_zero[simp]: "\<lbrakk>am ! n = (0::nat); n < length am\<rbrakk> \<Longrightarrow> am[n := 0] = am" |
|
174 apply(simp add: list_update_same_conv) |
|
175 done |
|
176 |
173 lemma addition_inv_init: |
177 lemma addition_inv_init: |
174 "\<lbrakk>m \<noteq> n; max m n < p; length lm > p; lm ! p = 0\<rbrakk> \<Longrightarrow> |
178 "\<lbrakk>m \<noteq> n; max m n < p; length lm > p; lm ! p = 0\<rbrakk> \<Longrightarrow> |
175 addition_inv (0, lm) m n p lm" |
179 addition_inv (0, lm) m n p lm" |
176 apply(simp add: addition_inv.simps Let_def) |
180 apply(simp add: addition_inv.simps Let_def ) |
177 apply(rule_tac x = "lm ! m" in exI, simp) |
181 apply(rule_tac x = "lm ! m" in exI, simp) |
178 done |
182 done |
179 |
183 |
180 lemma abs_fetch_0[simp]: "abc_fetch 0 (addition m n p) = Some (Dec m 4)" |
184 lemma abs_fetch[simp]: |
181 by(simp add: abc_fetch.simps addition.simps) |
185 "abc_fetch 0 (addition m n p) = Some (Dec m 4)" |
182 |
186 "abc_fetch (Suc 0) (addition m n p) = Some (Inc n)" |
183 lemma abs_fetch_1[simp]: "abc_fetch (Suc 0) (addition m n p) = Some (Inc n)" |
187 "abc_fetch 2 (addition m n p) = Some (Inc p)" |
184 by(simp add: abc_fetch.simps addition.simps) |
188 "abc_fetch 3 (addition m n p) = Some (Goto 0)" |
185 |
189 "abc_fetch 4 (addition m n p) = Some (Dec p 7)" |
186 lemma abs_fetch_2[simp]: "abc_fetch 2 (addition m n p) = Some (Inc p)" |
190 "abc_fetch 5 (addition m n p) = Some (Inc m)" |
187 by(simp add: abc_fetch.simps addition.simps) |
191 "abc_fetch 6 (addition m n p) = Some (Goto 4)" |
188 |
192 by(simp_all add: abc_fetch.simps addition.simps) |
189 lemma abs_fetch_3[simp]: "abc_fetch 3 (addition m n p) = Some (Goto 0)" |
|
190 by(simp add: abc_fetch.simps addition.simps) |
|
191 |
|
192 lemma abs_fetch_4[simp]: "abc_fetch 4 (addition m n p) = Some (Dec p 7)" |
|
193 by(simp add: abc_fetch.simps addition.simps) |
|
194 |
|
195 lemma abs_fetch_5[simp]: "abc_fetch 5 (addition m n p) = Some (Inc m)" |
|
196 by(simp add: abc_fetch.simps addition.simps) |
|
197 |
|
198 lemma abs_fetch_6[simp]: "abc_fetch 6 (addition m n p) = Some (Goto 4)" |
|
199 by(simp add: abc_fetch.simps addition.simps) |
|
200 |
193 |
201 lemma exists_small_list_elem1[simp]: |
194 lemma exists_small_list_elem1[simp]: |
202 "\<lbrakk>m \<noteq> n; p < length lm; lm ! p = 0; m < p; n < p; x \<le> lm ! m; 0 < x\<rbrakk> |
195 "\<lbrakk>m \<noteq> n; p < length lm; lm ! p = 0; m < p; n < p; x \<le> lm ! m; 0 < x\<rbrakk> |
203 \<Longrightarrow> \<exists>xa<lm ! m. lm[m := x, n := lm ! n + lm ! m - x, |
196 \<Longrightarrow> \<exists>xa<lm ! m. lm[m := x, n := lm ! n + lm ! m - x, |
204 p := lm ! m - x, m := x - Suc 0] = |
197 p := lm ! m - x, m := x - Suc 0] = |
286 apply(simp_all add: addition.simps abc_steps_l.simps) |
279 apply(simp_all add: addition.simps abc_steps_l.simps) |
287 apply(auto simp add: addition_LE_def lex_triple_def lex_pair_def |
280 apply(auto simp add: addition_LE_def lex_triple_def lex_pair_def |
288 abc_step_l.simps addition_inv.simps |
281 abc_step_l.simps addition_inv.simps |
289 abc_lm_v.simps abc_lm_s.simps nth_append |
282 abc_lm_v.simps abc_lm_s.simps nth_append |
290 split: if_splits) |
283 split: if_splits) |
291 apply(rule_tac [!] x = x in exI, simp_all add: list_update_overwrite Suc_diff_Suc) |
284 apply(rule_tac [!] x = x in exI, simp_all add: list_update_overwrite Suc_diff_Suc ) |
292 by (metis list_update_overwrite list_update_swap nat_neq_iff) |
285 by (metis list_update_overwrite list_update_swap nat_neq_iff) |
293 |
286 |
294 lemma addition_correct': |
287 lemma addition_correct': |
295 "\<lbrakk>m \<noteq> n; max m n < p; length lm > p; lm ! p = 0\<rbrakk> \<Longrightarrow> |
288 "\<lbrakk>m \<noteq> n; max m n < p; length lm > p; lm ! p = 0\<rbrakk> \<Longrightarrow> |
296 \<exists> stp. (\<lambda> (as, lm'). as = 7 \<and> addition_inv (as, lm') m n p lm) |
289 \<exists> stp. (\<lambda> (as, lm'). as = 7 \<and> addition_inv (as, lm') m n p lm) |
477 apply(simp add: abc_steps_l.simps mv_box_inv.simps) |
470 apply(simp add: abc_steps_l.simps mv_box_inv.simps) |
478 apply(rule_tac x = "initlm ! m" in exI, |
471 apply(rule_tac x = "initlm ! m" in exI, |
479 rule_tac x = "initlm ! n" in exI, simp) |
472 rule_tac x = "initlm ! n" in exI, simp) |
480 done |
473 done |
481 |
474 |
482 lemma abc_fetch_0[simp]: "abc_fetch 0 (mv_box m n) = Some (Dec m 3)" |
475 lemma abc_fetch[simp]: |
483 apply(simp add: mv_box.simps abc_fetch.simps) |
476 "abc_fetch 0 (mv_box m n) = Some (Dec m 3)" |
484 done |
477 "abc_fetch (Suc 0) (mv_box m n) = Some (Inc n)" |
485 |
478 "abc_fetch 2 (mv_box m n) = Some (Goto 0)" |
486 lemma abc_fetch_1[simp]: "abc_fetch (Suc 0) (mv_box m n) = |
479 "abc_fetch 3 (mv_box m n) = None" |
487 Some (Inc n)" |
480 apply(simp_all add: mv_box.simps abc_fetch.simps) |
488 apply(simp add: mv_box.simps abc_fetch.simps) |
|
489 done |
|
490 |
|
491 lemma abc_fetch_2[simp]: "abc_fetch 2 (mv_box m n) = Some (Goto 0)" |
|
492 apply(simp add: mv_box.simps abc_fetch.simps) |
|
493 done |
|
494 |
|
495 lemma abc_fetch_3[simp]: "abc_fetch 3 (mv_box m n) = None" |
|
496 apply(simp add: mv_box.simps abc_fetch.simps) |
|
497 done |
481 done |
498 |
482 |
499 lemma replicate_Suc_iff_anywhere: "x # x\<up>b @ ys = x\<up>(Suc b) @ ys" |
483 lemma replicate_Suc_iff_anywhere: "x # x\<up>b @ ys = x\<up>(Suc b) @ ys" |
500 by simp |
484 by simp |
501 |
485 |
2582 apply(subgoal_tac "b \<le> start_of (layout_of ap) (Suc k)") |
2566 apply(subgoal_tac "b \<le> start_of (layout_of ap) (Suc k)") |
2583 apply(subgoal_tac "start_of (layout_of ap) (Suc k) \<le> start_of (layout_of ap) (length ap) ") |
2567 apply(subgoal_tac "start_of (layout_of ap) (Suc k) \<le> start_of (layout_of ap) (length ap) ") |
2584 apply(arith) |
2568 apply(arith) |
2585 apply(case_tac "Suc k = length ap", simp) |
2569 apply(case_tac "Suc k = length ap", simp) |
2586 apply(rule_tac start_of_less, simp) |
2570 apply(rule_tac start_of_less, simp) |
2587 apply(auto simp: tinc_b_def shift.simps start_of_suc_inc length_of.simps startof_not0) |
2571 apply(auto simp: tinc_b_def shift.simps start_of_suc_inc length_of.simps ) |
2588 done |
2572 done |
2589 |
2573 |
2590 lemma findnth_le[elim]: |
2574 lemma findnth_le[elim]: |
2591 "(a, b) \<in> set (shift (findnth n) (start_of (layout_of ap) k - Suc 0)) |
2575 "(a, b) \<in> set (shift (findnth n) (start_of (layout_of ap) k - Suc 0)) |
2592 \<Longrightarrow> b \<le> Suc (start_of (layout_of ap) k + 2 * n)" |
2576 \<Longrightarrow> b \<le> Suc (start_of (layout_of ap) k + 2 * n)" |
2605 apply(arith) |
2589 apply(arith) |
2606 apply(case_tac "Suc k = length ap", simp) |
2590 apply(case_tac "Suc k = length ap", simp) |
2607 apply(rule_tac start_of_less, simp) |
2591 apply(rule_tac start_of_less, simp) |
2608 apply(subgoal_tac "b \<le> start_of (layout_of ap) k + 2*n + 1 \<and> |
2592 apply(subgoal_tac "b \<le> start_of (layout_of ap) k + 2*n + 1 \<and> |
2609 start_of (layout_of ap) k + 2*n + 1 \<le> start_of (layout_of ap) (Suc k)", auto) |
2593 start_of (layout_of ap) k + 2*n + 1 \<le> start_of (layout_of ap) (Suc k)", auto) |
2610 apply(auto simp: tinc_b_def shift.simps length_of.simps startof_not0 start_of_suc_inc) |
2594 apply(auto simp: tinc_b_def shift.simps length_of.simps start_of_suc_inc) |
2611 done |
2595 done |
2612 |
2596 |
2613 lemma start_of_eq: "length ap < as \<Longrightarrow> start_of (layout_of ap) as = start_of (layout_of ap) (length ap)" |
2597 lemma start_of_eq: "length ap < as \<Longrightarrow> start_of (layout_of ap) as = start_of (layout_of ap) (length ap)" |
2614 apply(induct as, simp) |
2598 apply(induct as, simp) |
2615 apply(case_tac "length ap < as", simp add: start_of.simps) |
2599 apply(case_tac "length ap < as", simp add: start_of.simps) |
2644 \<Longrightarrow> b \<le> start_of (layout_of ap) (length ap)" |
2628 \<Longrightarrow> b \<le> start_of (layout_of ap) (length ap)" |
2645 apply(subgoal_tac "2*n + start_of (layout_of ap) k + 16 \<le> start_of (layout_of ap) (length ap) \<and> start_of (layout_of ap) k > 0") |
2629 apply(subgoal_tac "2*n + start_of (layout_of ap) k + 16 \<le> start_of (layout_of ap) (length ap) \<and> start_of (layout_of ap) k > 0") |
2646 prefer 2 |
2630 prefer 2 |
2647 apply(subgoal_tac "start_of (layout_of ap) (Suc k) = start_of (layout_of ap) k + 2*n + 16 |
2631 apply(subgoal_tac "start_of (layout_of ap) (Suc k) = start_of (layout_of ap) k + 2*n + 16 |
2648 \<and> start_of (layout_of ap) (Suc k) \<le> start_of (layout_of ap) (length ap)") |
2632 \<and> start_of (layout_of ap) (Suc k) \<le> start_of (layout_of ap) (length ap)") |
2649 apply(simp add: startof_not0, rule_tac conjI) |
2633 apply(simp, rule_tac conjI) |
2650 apply(simp add: start_of_suc_dec) |
2634 apply(simp add: start_of_suc_dec) |
2651 apply(rule_tac start_of_all_le) |
2635 apply(rule_tac start_of_all_le) |
2652 apply(auto simp: tdec_b_def shift.simps) |
2636 apply(auto simp: tdec_b_def shift.simps) |
2653 done |
2637 done |
2654 |
2638 |