author | Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at> |
Fri, 21 Dec 2018 15:30:24 +0100 | |
changeset 291 | 93db7414931d |
parent 290 | 6e1c03614d36 |
child 292 | 293e9c6f22e1 |
permissions | -rw-r--r-- |
163
67063c5365e1
changed theory names to uppercase
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
131
diff
changeset
|
1 |
theory Recursive |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2 |
imports Abacus Rec_Def Abacus_Hoare |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
begin |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
fun addition :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> abc_prog" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
where |
166
99a180fd4194
removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
163
diff
changeset
|
7 |
"addition m n p = [Dec m 4, Inc n, Inc p, Goto 0, Dec p 7, Inc m, Goto 4]" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
9 |
fun mv_box :: "nat \<Rightarrow> nat \<Rightarrow> abc_prog" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
10 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
11 |
"mv_box m n = [Dec m 3, Inc n, Goto 0]" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
12 |
|
166
99a180fd4194
removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
163
diff
changeset
|
13 |
text {* The compilation of @{text "z"}-operator. *} |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
14 |
definition rec_ci_z :: "abc_inst list" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
15 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
16 |
"rec_ci_z \<equiv> [Goto 1]" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
17 |
|
166
99a180fd4194
removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
163
diff
changeset
|
18 |
text {* The compilation of @{text "s"}-operator. *} |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
19 |
definition rec_ci_s :: "abc_inst list" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
20 |
where |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
21 |
"rec_ci_s \<equiv> (addition 0 1 2 [+] [Inc 1])" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
22 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
23 |
|
166
99a180fd4194
removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
163
diff
changeset
|
24 |
text {* The compilation of @{text "id i j"}-operator *} |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
25 |
fun rec_ci_id :: "nat \<Rightarrow> nat \<Rightarrow> abc_inst list" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
26 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
27 |
"rec_ci_id i j = addition j i (i + 1)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
28 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
29 |
fun mv_boxes :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> abc_inst list" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
30 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
31 |
"mv_boxes ab bb 0 = []" | |
166
99a180fd4194
removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
163
diff
changeset
|
32 |
"mv_boxes ab bb (Suc n) = mv_boxes ab bb n [+] mv_box (ab + n) (bb + n)" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
fun empty_boxes :: "nat \<Rightarrow> abc_inst list" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
35 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
36 |
"empty_boxes 0 = []" | |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
37 |
"empty_boxes (Suc n) = empty_boxes n [+] [Dec n 2, Goto 0]" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
38 |
|
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
39 |
fun cn_merge_gs :: |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
40 |
"(abc_inst list \<times> nat \<times> nat) list \<Rightarrow> nat \<Rightarrow> abc_inst list" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
41 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
42 |
"cn_merge_gs [] p = []" | |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
43 |
"cn_merge_gs (g # gs) p = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
44 |
(let (gprog, gpara, gn) = g in |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
45 |
gprog [+] mv_box gpara p [+] cn_merge_gs gs (Suc p))" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
46 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
47 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
48 |
text {* |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
49 |
The compiler of recursive functions, where @{text "rec_ci recf"} return |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
50 |
@{text "(ap, arity, fp)"}, where @{text "ap"} is the Abacus program, @{text "arity"} is the |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
51 |
arity of the recursive function @{text "recf"}, |
166
99a180fd4194
removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
163
diff
changeset
|
52 |
@{text "fp"} is the amount of memory which is going to be |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
53 |
used by @{text "ap"} for its execution. |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
54 |
*} |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
55 |
|
203
514809bb7ce4
simplified slightly rec_compilation function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
190
diff
changeset
|
56 |
fun rec_ci :: "recf \<Rightarrow> abc_inst list \<times> nat \<times> nat" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
57 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
58 |
"rec_ci z = (rec_ci_z, 1, 2)" | |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
59 |
"rec_ci s = (rec_ci_s, 1, 3)" | |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
60 |
"rec_ci (id m n) = (rec_ci_id m n, m, m + 2)" | |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
61 |
"rec_ci (Cn n f gs) = |
203
514809bb7ce4
simplified slightly rec_compilation function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
190
diff
changeset
|
62 |
(let cied_gs = map (\<lambda> g. rec_ci g) gs in |
514809bb7ce4
simplified slightly rec_compilation function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
190
diff
changeset
|
63 |
let (fprog, fpara, fn) = rec_ci f in |
514809bb7ce4
simplified slightly rec_compilation function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
190
diff
changeset
|
64 |
let pstr = Max (set (Suc n # fn # (map (\<lambda> (aprog, p, n). n) cied_gs))) in |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
65 |
let qstr = pstr + Suc (length gs) in |
203
514809bb7ce4
simplified slightly rec_compilation function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
190
diff
changeset
|
66 |
(cn_merge_gs cied_gs pstr [+] mv_boxes 0 qstr n [+] |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
67 |
mv_boxes pstr 0 (length gs) [+] fprog [+] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
68 |
mv_box fpara pstr [+] empty_boxes (length gs) [+] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
69 |
mv_box pstr n [+] mv_boxes qstr 0 n, n, qstr + n))" | |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
70 |
"rec_ci (Pr n f g) = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
71 |
(let (fprog, fpara, fn) = rec_ci f in |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
72 |
let (gprog, gpara, gn) = rec_ci g in |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
73 |
let p = Max (set ([n + 3, fn, gn])) in |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
74 |
let e = length gprog + 7 in |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
75 |
(mv_box n p [+] fprog [+] mv_box n (Suc n) [+] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
76 |
(([Dec p e] [+] gprog [+] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
77 |
[Inc n, Dec (Suc n) 3, Goto 1]) @ |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
78 |
[Dec (Suc (Suc n)) 0, Inc (Suc n), Goto (length gprog + 4)]), |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
79 |
Suc n, p + 1))" | |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
80 |
"rec_ci (Mn n f) = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
81 |
(let (fprog, fpara, fn) = rec_ci f in |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
82 |
let len = length (fprog) in |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
83 |
(fprog @ [Dec (Suc n) (len + 5), Dec (Suc n) (len + 3), |
166
99a180fd4194
removed some dead code
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
163
diff
changeset
|
84 |
Goto (len + 1), Inc n, Goto 0], n, max (Suc n) fn))" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
85 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
86 |
declare rec_ci.simps [simp del] rec_ci_s_def[simp del] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
87 |
rec_ci_z_def[simp del] rec_ci_id.simps[simp del] |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
88 |
mv_boxes.simps[simp del] |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
89 |
mv_box.simps[simp del] addition.simps[simp del] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
90 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
91 |
declare abc_steps_l.simps[simp del] abc_fetch.simps[simp del] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
92 |
abc_step_l.simps[simp del] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
93 |
|
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
94 |
inductive_cases terminate_pr_reverse: "terminate (Pr n f g) xs" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
95 |
|
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
96 |
inductive_cases terminate_z_reverse[elim!]: "terminate z xs" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
97 |
|
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
98 |
inductive_cases terminate_s_reverse[elim!]: "terminate s xs" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
99 |
|
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
100 |
inductive_cases terminate_id_reverse[elim!]: "terminate (id m n) xs" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
101 |
|
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
102 |
inductive_cases terminate_cn_reverse[elim!]: "terminate (Cn n f gs) xs" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
103 |
|
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
104 |
inductive_cases terminate_mn_reverse[elim!]:"terminate (Mn n f) xs" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
105 |
|
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
106 |
fun addition_inv :: "nat \<times> nat list \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
107 |
nat list \<Rightarrow> bool" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
108 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
109 |
"addition_inv (as, lm') m n p lm = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
110 |
(let sn = lm ! n in |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
111 |
let sm = lm ! m in |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
112 |
lm ! p = 0 \<and> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
113 |
(if as = 0 then \<exists> x. x \<le> lm ! m \<and> lm' = lm[m := x, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
114 |
n := (sn + sm - x), p := (sm - x)] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
115 |
else if as = 1 then \<exists> x. x < lm ! m \<and> lm' = lm[m := x, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
116 |
n := (sn + sm - x - 1), p := (sm - x - 1)] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
117 |
else if as = 2 then \<exists> x. x < lm ! m \<and> lm' = lm[m := x, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
118 |
n := (sn + sm - x), p := (sm - x - 1)] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
119 |
else if as = 3 then \<exists> x. x < lm ! m \<and> lm' = lm[m := x, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
120 |
n := (sn + sm - x), p := (sm - x)] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
121 |
else if as = 4 then \<exists> x. x \<le> lm ! m \<and> lm' = lm[m := x, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
122 |
n := (sn + sm), p := (sm - x)] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
123 |
else if as = 5 then \<exists> x. x < lm ! m \<and> lm' = lm[m := x, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
124 |
n := (sn + sm), p := (sm - x - 1)] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
125 |
else if as = 6 then \<exists> x. x < lm ! m \<and> lm' = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
126 |
lm[m := Suc x, n := (sn + sm), p := (sm - x - 1)] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
127 |
else if as = 7 then lm' = lm[m := sm, n := (sn + sm)] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
128 |
else False))" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
129 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
130 |
fun addition_stage1 :: "nat \<times> nat list \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
131 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
132 |
"addition_stage1 (as, lm) m p = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
133 |
(if as = 0 \<or> as = 1 \<or> as = 2 \<or> as = 3 then 2 |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
134 |
else if as = 4 \<or> as = 5 \<or> as = 6 then 1 |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
135 |
else 0)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
136 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
137 |
fun addition_stage2 :: "nat \<times> nat list \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
138 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
139 |
"addition_stage2 (as, lm) m p = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
140 |
(if 0 \<le> as \<and> as \<le> 3 then lm ! m |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
141 |
else if 4 \<le> as \<and> as \<le> 6 then lm ! p |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
142 |
else 0)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
143 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
144 |
fun addition_stage3 :: "nat \<times> nat list \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
145 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
146 |
"addition_stage3 (as, lm) m p = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
147 |
(if as = 1 then 4 |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
148 |
else if as = 2 then 3 |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
149 |
else if as = 3 then 2 |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
150 |
else if as = 0 then 1 |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
151 |
else if as = 5 then 2 |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
152 |
else if as = 6 then 1 |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
153 |
else if as = 4 then 0 |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
154 |
else 0)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
155 |
|
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
156 |
fun addition_measure :: "((nat \<times> nat list) \<times> nat \<times> nat) \<Rightarrow> |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
157 |
(nat \<times> nat \<times> nat)" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
158 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
159 |
"addition_measure ((as, lm), m, p) = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
160 |
(addition_stage1 (as, lm) m p, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
161 |
addition_stage2 (as, lm) m p, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
162 |
addition_stage3 (as, lm) m p)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
163 |
|
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
164 |
definition addition_LE :: "(((nat \<times> nat list) \<times> nat \<times> nat) \<times> |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
165 |
((nat \<times> nat list) \<times> nat \<times> nat)) set" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
166 |
where "addition_LE \<equiv> (inv_image lex_triple addition_measure)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
167 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
168 |
lemma wf_additon_LE[simp]: "wf addition_LE" |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
169 |
by(auto simp: addition_LE_def lex_triple_def lex_pair_def) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
170 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
171 |
declare addition_inv.simps[simp del] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
172 |
|
291
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
173 |
lemma update_zero_to_zero[simp]: "\<lbrakk>am ! n = (0::nat); n < length am\<rbrakk> \<Longrightarrow> am[n := 0] = am" |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
174 |
apply(simp add: list_update_same_conv) |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
175 |
done |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
176 |
|
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
177 |
lemma addition_inv_init: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
178 |
"\<lbrakk>m \<noteq> n; max m n < p; length lm > p; lm ! p = 0\<rbrakk> \<Longrightarrow> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
179 |
addition_inv (0, lm) m n p lm" |
291
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
180 |
apply(simp add: addition_inv.simps Let_def ) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
181 |
apply(rule_tac x = "lm ! m" in exI, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
182 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
183 |
|
291
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
184 |
lemma abs_fetch[simp]: |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
185 |
"abc_fetch 0 (addition m n p) = Some (Dec m 4)" |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
186 |
"abc_fetch (Suc 0) (addition m n p) = Some (Inc n)" |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
187 |
"abc_fetch 2 (addition m n p) = Some (Inc p)" |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
188 |
"abc_fetch 3 (addition m n p) = Some (Goto 0)" |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
189 |
"abc_fetch 4 (addition m n p) = Some (Dec p 7)" |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
190 |
"abc_fetch 5 (addition m n p) = Some (Inc m)" |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
191 |
"abc_fetch 6 (addition m n p) = Some (Goto 4)" |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
192 |
by(simp_all add: abc_fetch.simps addition.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
193 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
194 |
lemma exists_small_list_elem1[simp]: |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
195 |
"\<lbrakk>m \<noteq> n; p < length lm; lm ! p = 0; m < p; n < p; x \<le> lm ! m; 0 < x\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
196 |
\<Longrightarrow> \<exists>xa<lm ! m. lm[m := x, n := lm ! n + lm ! m - x, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
197 |
p := lm ! m - x, m := x - Suc 0] = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
198 |
lm[m := xa, n := lm ! n + lm ! m - Suc xa, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
199 |
p := lm ! m - Suc xa]" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
200 |
apply(case_tac x, simp, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
201 |
apply(rule_tac x = nat in exI, simp add: list_update_swap |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
202 |
list_update_overwrite) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
203 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
204 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
205 |
lemma exists_small_list_elem2[simp]: |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
206 |
"\<lbrakk>m \<noteq> n; p < length lm; lm ! p = 0; m < p; n < p; x < lm ! m\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
207 |
\<Longrightarrow> \<exists>xa<lm ! m. lm[m := x, n := lm ! n + lm ! m - Suc x, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
208 |
p := lm ! m - Suc x, n := lm ! n + lm ! m - x] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
209 |
= lm[m := xa, n := lm ! n + lm ! m - xa, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
210 |
p := lm ! m - Suc xa]" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
211 |
apply(rule_tac x = x in exI, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
212 |
simp add: list_update_swap list_update_overwrite) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
213 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
214 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
215 |
lemma exists_small_list_elem3[simp]: |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
216 |
"\<lbrakk>m \<noteq> n; p < length lm; lm ! p = 0; m < p; n < p; x < lm ! m\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
217 |
\<Longrightarrow> \<exists>xa<lm ! m. lm[m := x, n := lm ! n + lm ! m - x, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
218 |
p := lm ! m - Suc x, p := lm ! m - x] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
219 |
= lm[m := xa, n := lm ! n + lm ! m - xa, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
220 |
p := lm ! m - xa]" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
221 |
apply(rule_tac x = x in exI, simp add: list_update_overwrite) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
222 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
223 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
224 |
lemma exists_small_list_elem4[simp]: |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
225 |
"\<lbrakk>m \<noteq> n; p < length lm; lm ! p = (0::nat); m < p; n < p; x < lm ! m\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
226 |
\<Longrightarrow> \<exists>xa\<le>lm ! m. lm[m := x, n := lm ! n + lm ! m - x, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
227 |
p := lm ! m - x] = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
228 |
lm[m := xa, n := lm ! n + lm ! m - xa, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
229 |
p := lm ! m - xa]" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
230 |
apply(rule_tac x = x in exI, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
231 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
232 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
233 |
lemma exists_small_list_elem5[simp]: |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
234 |
"\<lbrakk>m \<noteq> n; p < length lm; lm ! p = 0; m < p; n < p; |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
235 |
x \<le> lm ! m; lm ! m \<noteq> x\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
236 |
\<Longrightarrow> \<exists>xa<lm ! m. lm[m := x, n := lm ! n + lm ! m, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
237 |
p := lm ! m - x, p := lm ! m - Suc x] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
238 |
= lm[m := xa, n := lm ! n + lm ! m, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
239 |
p := lm ! m - Suc xa]" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
240 |
apply(rule_tac x = x in exI, simp add: list_update_overwrite) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
241 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
242 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
243 |
lemma exists_small_list_elem6[simp]: |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
244 |
"\<lbrakk>m \<noteq> n; p < length lm; lm ! p = 0; m < p; n < p; x < lm ! m\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
245 |
\<Longrightarrow> \<exists>xa<lm ! m. lm[m := x, n := lm ! n + lm ! m, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
246 |
p := lm ! m - Suc x, m := Suc x] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
247 |
= lm[m := Suc xa, n := lm ! n + lm ! m, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
248 |
p := lm ! m - Suc xa]" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
249 |
apply(rule_tac x = x in exI, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
250 |
simp add: list_update_swap list_update_overwrite) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
251 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
252 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
253 |
lemma exists_small_list_elem7[simp]: |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
254 |
"\<lbrakk>m \<noteq> n; p < length lm; lm ! p = 0; m < p; n < p; x < lm ! m\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
255 |
\<Longrightarrow> \<exists>xa\<le>lm ! m. lm[m := Suc x, n := lm ! n + lm ! m, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
256 |
p := lm ! m - Suc x] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
257 |
= lm[m := xa, n := lm ! n + lm ! m, p := lm ! m - xa]" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
258 |
apply(rule_tac x = "Suc x" in exI, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
259 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
260 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
261 |
lemma abc_steps_zero: "abc_steps_l asm ap 0 = asm" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
262 |
apply(case_tac asm, simp add: abc_steps_l.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
263 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
264 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
265 |
declare Let_def[simp] |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
266 |
lemma addition_halt_lemma: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
267 |
"\<lbrakk>m \<noteq> n; max m n < p; length lm > p; lm ! p = 0\<rbrakk> \<Longrightarrow> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
268 |
\<forall>na. \<not> (\<lambda>(as, lm') (m, p). as = 7) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
269 |
(abc_steps_l (0, lm) (addition m n p) na) (m, p) \<and> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
270 |
addition_inv (abc_steps_l (0, lm) (addition m n p) na) m n p lm |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
271 |
\<longrightarrow> addition_inv (abc_steps_l (0, lm) (addition m n p) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
272 |
(Suc na)) m n p lm |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
273 |
\<and> ((abc_steps_l (0, lm) (addition m n p) (Suc na), m, p), |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
274 |
abc_steps_l (0, lm) (addition m n p) na, m, p) \<in> addition_LE" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
275 |
apply(rule allI, rule impI, simp add: abc_step_red2) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
276 |
apply(case_tac "(abc_steps_l (0, lm) (addition m n p) na)", simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
277 |
apply(auto split:if_splits simp add: addition_inv.simps |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
278 |
abc_steps_zero) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
279 |
apply(simp_all add: addition.simps abc_steps_l.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
280 |
apply(auto simp add: addition_LE_def lex_triple_def lex_pair_def |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
281 |
abc_step_l.simps addition_inv.simps |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
282 |
abc_lm_v.simps abc_lm_s.simps nth_append |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
283 |
split: if_splits) |
291
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
284 |
apply(rule_tac [!] x = x in exI, simp_all add: list_update_overwrite Suc_diff_Suc ) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
285 |
by (metis list_update_overwrite list_update_swap nat_neq_iff) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
286 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
287 |
lemma addition_correct': |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
288 |
"\<lbrakk>m \<noteq> n; max m n < p; length lm > p; lm ! p = 0\<rbrakk> \<Longrightarrow> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
289 |
\<exists> stp. (\<lambda> (as, lm'). as = 7 \<and> addition_inv (as, lm') m n p lm) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
290 |
(abc_steps_l (0, lm) (addition m n p) stp)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
291 |
apply(insert halt_lemma2[of addition_LE |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
292 |
"\<lambda> ((as, lm'), m, p). addition_inv (as, lm') m n p lm" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
293 |
"\<lambda> stp. (abc_steps_l (0, lm) (addition m n p) stp, m, p)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
294 |
"\<lambda> ((as, lm'), m, p). as = 7"], |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
295 |
simp add: abc_steps_zero addition_inv_init) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
296 |
apply(drule_tac addition_halt_lemma, simp, simp, simp, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
297 |
simp, erule_tac exE) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
298 |
apply(rule_tac x = na in exI, |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
299 |
case_tac "(abc_steps_l (0, lm) (addition m n p) na)", auto) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
300 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
301 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
302 |
lemma length_addition[simp]: "length (addition a b c) = 7" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
303 |
by(auto simp: addition.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
304 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
305 |
lemma addition_correct: |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
306 |
assumes "m \<noteq> n" "max m n < p" "length lm > p" "lm ! p = 0" |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
307 |
shows "{\<lambda> a. a = lm} (addition m n p) {\<lambda> nl. addition_inv (7, nl) m n p lm}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
308 |
using assms |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
309 |
proof(rule_tac abc_Hoare_haltI, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
310 |
fix lma |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
311 |
assume "m \<noteq> n" "m < p \<and> n < p" "p < length lm" "lm ! p = 0" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
312 |
then have "\<exists> stp. (\<lambda> (as, lm'). as = 7 \<and> addition_inv (as, lm') m n p lm) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
313 |
(abc_steps_l (0, lm) (addition m n p) stp)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
314 |
by(rule_tac addition_correct', auto simp: addition_inv.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
315 |
thus "\<exists>na. abc_final (abc_steps_l (0, lm) (addition m n p) na) (addition m n p) \<and> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
316 |
(\<lambda>nl. addition_inv (7, nl) m n p lm) abc_holds_for abc_steps_l (0, lm) (addition m n p) na" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
317 |
apply(erule_tac exE) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
318 |
apply(rule_tac x = stp in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
319 |
apply(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
320 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
321 |
qed |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
322 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
323 |
lemma compile_s_correct': |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
324 |
"{\<lambda>nl. nl = n # 0 \<up> 2 @ anything} addition 0 (Suc 0) 2 [+] [Inc (Suc 0)] {\<lambda>nl. nl = n # Suc n # 0 # anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
325 |
proof(rule_tac abc_Hoare_plus_halt) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
326 |
show "{\<lambda>nl. nl = n # 0 \<up> 2 @ anything} addition 0 (Suc 0) 2 {\<lambda> nl. addition_inv (7, nl) 0 (Suc 0) 2 (n # 0 \<up> 2 @ anything)}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
327 |
by(rule_tac addition_correct, auto simp: numeral_2_eq_2) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
328 |
next |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
329 |
show "{\<lambda>nl. addition_inv (7, nl) 0 (Suc 0) 2 (n # 0 \<up> 2 @ anything)} [Inc (Suc 0)] {\<lambda>nl. nl = n # Suc n # 0 # anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
330 |
by(rule_tac abc_Hoare_haltI, rule_tac x = 1 in exI, auto simp: addition_inv.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
331 |
abc_steps_l.simps abc_step_l.simps abc_fetch.simps numeral_2_eq_2 abc_lm_s.simps abc_lm_v.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
332 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
333 |
|
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
334 |
declare rec_exec.simps[simp del] |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
335 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
336 |
lemma abc_comp_commute: "(A [+] B) [+] C = A [+] (B [+] C)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
337 |
apply(auto simp: abc_comp.simps abc_shift.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
338 |
apply(case_tac x, auto) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
339 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
340 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
341 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
342 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
343 |
lemma compile_z_correct: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
344 |
"\<lbrakk>rec_ci z = (ap, arity, fp); rec_exec z [n] = r\<rbrakk> \<Longrightarrow> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
345 |
{\<lambda>nl. nl = n # 0 \<up> (fp - arity) @ anything} ap {\<lambda>nl. nl = n # r # 0 \<up> (fp - Suc arity) @ anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
346 |
apply(rule_tac abc_Hoare_haltI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
347 |
apply(rule_tac x = 1 in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
348 |
apply(auto simp: abc_steps_l.simps rec_ci.simps rec_ci_z_def |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
349 |
numeral_2_eq_2 abc_fetch.simps abc_step_l.simps rec_exec.simps) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
350 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
351 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
352 |
lemma compile_s_correct: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
353 |
"\<lbrakk>rec_ci s = (ap, arity, fp); rec_exec s [n] = r\<rbrakk> \<Longrightarrow> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
354 |
{\<lambda>nl. nl = n # 0 \<up> (fp - arity) @ anything} ap {\<lambda>nl. nl = n # r # 0 \<up> (fp - Suc arity) @ anything}" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
355 |
apply(auto simp: rec_ci.simps rec_ci_s_def compile_s_correct' rec_exec.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
356 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
357 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
358 |
lemma compile_id_correct': |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
359 |
assumes "n < length args" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
360 |
shows "{\<lambda>nl. nl = args @ 0 \<up> 2 @ anything} addition n (length args) (Suc (length args)) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
361 |
{\<lambda>nl. nl = args @ rec_exec (recf.id (length args) n) args # 0 # anything}" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
362 |
proof - |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
363 |
have "{\<lambda>nl. nl = args @ 0 \<up> 2 @ anything} addition n (length args) (Suc (length args)) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
364 |
{\<lambda>nl. addition_inv (7, nl) n (length args) (Suc (length args)) (args @ 0 \<up> 2 @ anything)}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
365 |
using assms |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
366 |
by(rule_tac addition_correct, auto simp: numeral_2_eq_2 nth_append) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
367 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
368 |
using assms |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
369 |
by(simp add: addition_inv.simps rec_exec.simps |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
370 |
nth_append numeral_2_eq_2 list_update_append) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
371 |
qed |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
372 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
373 |
lemma compile_id_correct: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
374 |
"\<lbrakk>n < m; length xs = m; rec_ci (recf.id m n) = (ap, arity, fp); rec_exec (recf.id m n) xs = r\<rbrakk> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
375 |
\<Longrightarrow> {\<lambda>nl. nl = xs @ 0 \<up> (fp - arity) @ anything} ap {\<lambda>nl. nl = xs @ r # 0 \<up> (fp - Suc arity) @ anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
376 |
apply(auto simp: rec_ci.simps rec_ci_id.simps compile_id_correct') |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
377 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
378 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
379 |
lemma cn_merge_gs_tl_app: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
380 |
"cn_merge_gs (gs @ [g]) pstr = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
381 |
cn_merge_gs gs pstr [+] cn_merge_gs [g] (pstr + length gs)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
382 |
apply(induct gs arbitrary: pstr, simp add: cn_merge_gs.simps, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
383 |
apply(simp add: abc_comp_commute) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
384 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
385 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
386 |
lemma footprint_ge: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
387 |
"rec_ci a = (p, arity, fp) \<Longrightarrow> arity < fp" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
388 |
apply(induct a) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
389 |
apply(auto simp: rec_ci.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
390 |
apply(case_tac "rec_ci a", simp) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
391 |
apply(case_tac "rec_ci a1", case_tac "rec_ci a2", auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
392 |
apply(case_tac "rec_ci a", auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
393 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
394 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
395 |
lemma param_pattern: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
396 |
"\<lbrakk>terminate f xs; rec_ci f = (p, arity, fp)\<rbrakk> \<Longrightarrow> length xs = arity" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
397 |
apply(induct arbitrary: p arity fp rule: terminate.induct) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
398 |
apply(auto simp: rec_ci.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
399 |
apply(case_tac "rec_ci f", simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
400 |
apply(case_tac "rec_ci f", case_tac "rec_ci g", simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
401 |
apply(case_tac "rec_ci f", case_tac "rec_ci gs", simp) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
402 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
403 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
404 |
lemma replicate_merge_anywhere: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
405 |
"x\<up>a @ x\<up>b @ ys = x\<up>(a+b) @ ys" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
406 |
by(simp add:replicate_add) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
407 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
408 |
fun mv_box_inv :: "nat \<times> nat list \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat list \<Rightarrow> bool" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
409 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
410 |
"mv_box_inv (as, lm) m n initlm = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
411 |
(let plus = initlm ! m + initlm ! n in |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
412 |
length initlm > max m n \<and> m \<noteq> n \<and> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
413 |
(if as = 0 then \<exists> k l. lm = initlm[m := k, n := l] \<and> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
414 |
k + l = plus \<and> k \<le> initlm ! m |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
415 |
else if as = 1 then \<exists> k l. lm = initlm[m := k, n := l] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
416 |
\<and> k + l + 1 = plus \<and> k < initlm ! m |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
417 |
else if as = 2 then \<exists> k l. lm = initlm[m := k, n := l] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
418 |
\<and> k + l = plus \<and> k \<le> initlm ! m |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
419 |
else if as = 3 then lm = initlm[m := 0, n := plus] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
420 |
else False))" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
421 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
422 |
fun mv_box_stage1 :: "nat \<times> nat list \<Rightarrow> nat \<Rightarrow> nat" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
423 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
424 |
"mv_box_stage1 (as, lm) m = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
425 |
(if as = 3 then 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
426 |
else 1)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
427 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
428 |
fun mv_box_stage2 :: "nat \<times> nat list \<Rightarrow> nat \<Rightarrow> nat" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
429 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
430 |
"mv_box_stage2 (as, lm) m = (lm ! m)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
431 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
432 |
fun mv_box_stage3 :: "nat \<times> nat list \<Rightarrow> nat \<Rightarrow> nat" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
433 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
434 |
"mv_box_stage3 (as, lm) m = (if as = 1 then 3 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
435 |
else if as = 2 then 2 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
436 |
else if as = 0 then 1 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
437 |
else 0)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
438 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
439 |
fun mv_box_measure :: "((nat \<times> nat list) \<times> nat) \<Rightarrow> (nat \<times> nat \<times> nat)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
440 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
441 |
"mv_box_measure ((as, lm), m) = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
442 |
(mv_box_stage1 (as, lm) m, mv_box_stage2 (as, lm) m, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
443 |
mv_box_stage3 (as, lm) m)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
444 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
445 |
definition lex_pair :: "((nat \<times> nat) \<times> nat \<times> nat) set" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
446 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
447 |
"lex_pair = less_than <*lex*> less_than" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
448 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
449 |
definition lex_triple :: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
450 |
"((nat \<times> (nat \<times> nat)) \<times> (nat \<times> (nat \<times> nat))) set" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
451 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
452 |
"lex_triple \<equiv> less_than <*lex*> lex_pair" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
453 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
454 |
definition mv_box_LE :: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
455 |
"(((nat \<times> nat list) \<times> nat) \<times> ((nat \<times> nat list) \<times> nat)) set" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
456 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
457 |
"mv_box_LE \<equiv> (inv_image lex_triple mv_box_measure)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
458 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
459 |
lemma wf_lex_triple: "wf lex_triple" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
460 |
by (auto intro:wf_lex_prod simp:lex_triple_def lex_pair_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
461 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
462 |
lemma wf_mv_box_le[intro]: "wf mv_box_LE" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
463 |
by(auto intro:wf_inv_image wf_lex_triple simp: mv_box_LE_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
464 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
465 |
declare mv_box_inv.simps[simp del] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
466 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
467 |
lemma mv_box_inv_init: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
468 |
"\<lbrakk>m < length initlm; n < length initlm; m \<noteq> n\<rbrakk> \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
469 |
mv_box_inv (0, initlm) m n initlm" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
470 |
apply(simp add: abc_steps_l.simps mv_box_inv.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
471 |
apply(rule_tac x = "initlm ! m" in exI, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
472 |
rule_tac x = "initlm ! n" in exI, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
473 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
474 |
|
291
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
475 |
lemma abc_fetch[simp]: |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
476 |
"abc_fetch 0 (mv_box m n) = Some (Dec m 3)" |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
477 |
"abc_fetch (Suc 0) (mv_box m n) = Some (Inc n)" |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
478 |
"abc_fetch 2 (mv_box m n) = Some (Goto 0)" |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
479 |
"abc_fetch 3 (mv_box m n) = None" |
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
480 |
apply(simp_all add: mv_box.simps abc_fetch.simps) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
481 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
482 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
483 |
lemma replicate_Suc_iff_anywhere: "x # x\<up>b @ ys = x\<up>(Suc b) @ ys" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
484 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
485 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
486 |
lemma exists_smaller_in_list0[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
487 |
"\<lbrakk>m \<noteq> n; m < length initlm; n < length initlm; |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
488 |
k + l = initlm ! m + initlm ! n; k \<le> initlm ! m; 0 < k\<rbrakk> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
489 |
\<Longrightarrow> \<exists>ka la. initlm[m := k, n := l, m := k - Suc 0] = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
490 |
initlm[m := ka, n := la] \<and> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
491 |
Suc (ka + la) = initlm ! m + initlm ! n \<and> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
492 |
ka < initlm ! m" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
493 |
apply(rule_tac x = "k - Suc 0" in exI, rule_tac x = l in exI, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
494 |
simp, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
495 |
apply(subgoal_tac |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
496 |
"initlm[m := k, n := l, m := k - Suc 0] = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
497 |
initlm[n := l, m := k, m := k - Suc 0]") |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
498 |
apply(simp add: list_update_overwrite ) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
499 |
apply(simp add: list_update_swap) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
500 |
apply(simp add: list_update_swap) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
501 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
502 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
503 |
lemma exists_smaller_in_list1[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
504 |
"\<lbrakk>m \<noteq> n; m < length initlm; n < length initlm; |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
505 |
Suc (k + l) = initlm ! m + initlm ! n; |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
506 |
k < initlm ! m\<rbrakk> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
507 |
\<Longrightarrow> \<exists>ka la. initlm[m := k, n := l, n := Suc l] = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
508 |
initlm[m := ka, n := la] \<and> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
509 |
ka + la = initlm ! m + initlm ! n \<and> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
510 |
ka \<le> initlm ! m" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
511 |
apply(rule_tac x = k in exI, rule_tac x = "Suc l" in exI, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
512 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
513 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
514 |
lemma abc_steps_prop[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
515 |
"\<lbrakk>length initlm > max m n; m \<noteq> n\<rbrakk> \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
516 |
\<forall>na. \<not> (\<lambda>(as, lm) m. as = 3) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
517 |
(abc_steps_l (0, initlm) (mv_box m n) na) m \<and> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
518 |
mv_box_inv (abc_steps_l (0, initlm) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
519 |
(mv_box m n) na) m n initlm \<longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
520 |
mv_box_inv (abc_steps_l (0, initlm) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
521 |
(mv_box m n) (Suc na)) m n initlm \<and> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
522 |
((abc_steps_l (0, initlm) (mv_box m n) (Suc na), m), |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
523 |
abc_steps_l (0, initlm) (mv_box m n) na, m) \<in> mv_box_LE" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
524 |
apply(rule allI, rule impI, simp add: abc_step_red2) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
525 |
apply(case_tac "(abc_steps_l (0, initlm) (mv_box m n) na)", |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
526 |
simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
527 |
apply(auto split:if_splits simp add:abc_steps_l.simps mv_box_inv.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
528 |
apply(auto simp add: mv_box_LE_def lex_triple_def lex_pair_def |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
529 |
abc_step_l.simps abc_steps_l.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
530 |
mv_box_inv.simps abc_lm_v.simps abc_lm_s.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
531 |
split: if_splits ) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
532 |
apply(rule_tac x = k in exI, rule_tac x = "Suc l" in exI, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
533 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
534 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
535 |
lemma mv_box_inv_halt: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
536 |
"\<lbrakk>length initlm > max m n; m \<noteq> n\<rbrakk> \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
537 |
\<exists> stp. (\<lambda> (as, lm). as = 3 \<and> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
538 |
mv_box_inv (as, lm) m n initlm) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
539 |
(abc_steps_l (0::nat, initlm) (mv_box m n) stp)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
540 |
apply(insert halt_lemma2[of mv_box_LE |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
541 |
"\<lambda> ((as, lm), m). mv_box_inv (as, lm) m n initlm" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
542 |
"\<lambda> stp. (abc_steps_l (0, initlm) (mv_box m n) stp, m)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
543 |
"\<lambda> ((as, lm), m). as = (3::nat)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
544 |
]) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
545 |
apply(insert wf_mv_box_le) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
546 |
apply(simp add: mv_box_inv_init abc_steps_zero) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
547 |
apply(erule_tac exE) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
548 |
apply(rule_tac x = na in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
549 |
apply(case_tac "(abc_steps_l (0, initlm) (mv_box m n) na)", |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
550 |
simp, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
551 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
552 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
553 |
lemma mv_box_halt_cond: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
554 |
"\<lbrakk>m \<noteq> n; mv_box_inv (a, b) m n lm; a = 3\<rbrakk> \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
555 |
b = lm[n := lm ! m + lm ! n, m := 0]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
556 |
apply(simp add: mv_box_inv.simps, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
557 |
apply(simp add: list_update_swap) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
558 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
559 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
560 |
lemma mv_box_correct': |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
561 |
"\<lbrakk>length lm > max m n; m \<noteq> n\<rbrakk> \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
562 |
\<exists> stp. abc_steps_l (0::nat, lm) (mv_box m n) stp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
563 |
= (3, (lm[n := (lm ! m + lm ! n)])[m := 0::nat])" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
564 |
apply(drule mv_box_inv_halt, simp, erule_tac exE) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
565 |
apply(rule_tac x = stp in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
566 |
apply(case_tac "abc_steps_l (0, lm) (mv_box m n) stp", |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
567 |
simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
568 |
apply(erule_tac mv_box_halt_cond, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
569 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
570 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
571 |
lemma length_mvbox[simp]: "length (mv_box m n) = 3" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
572 |
by(simp add: mv_box.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
573 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
574 |
lemma mv_box_correct: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
575 |
"\<lbrakk>length lm > max m n; m\<noteq>n\<rbrakk> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
576 |
\<Longrightarrow> {\<lambda> nl. nl = lm} mv_box m n {\<lambda> nl. nl = lm[n := (lm ! m + lm ! n), m:=0]}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
577 |
apply(drule_tac mv_box_correct', simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
578 |
apply(auto simp: abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
579 |
apply(rule_tac x = stp in exI, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
580 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
581 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
582 |
declare list_update.simps(2)[simp del] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
583 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
584 |
lemma zero_case_rec_exec[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
585 |
"\<lbrakk>length xs < gf; gf \<le> ft; n < length gs\<rbrakk> |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
586 |
\<Longrightarrow> (rec_exec (gs ! n) xs # 0 \<up> (ft - Suc (length xs)) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 # 0 \<up> length xs @ anything) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
587 |
[ft + n - length xs := rec_exec (gs ! n) xs, 0 := 0] = |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
588 |
0 \<up> (ft - length xs) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ rec_exec (gs ! n) xs # 0 \<up> (length gs - Suc n) @ 0 # 0 \<up> length xs @ anything" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
589 |
using list_update_append[of "rec_exec (gs ! n) xs # 0 \<up> (ft - Suc (length xs)) @ map (\<lambda>i. rec_exec i xs) (take n gs)" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
590 |
"0 \<up> (length gs - n) @ 0 # 0 \<up> length xs @ anything" "ft + n - length xs" "rec_exec (gs ! n) xs"] |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
591 |
apply(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
592 |
apply(case_tac "length gs - n", simp, simp add: list_update.simps replicate_Suc_iff_anywhere Suc_diff_Suc del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
593 |
apply(simp add: list_update.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
594 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
595 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
596 |
lemma compile_cn_gs_correct': |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
597 |
assumes |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
598 |
g_cond: "\<forall>g\<in>set (take n gs). terminate g xs \<and> |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
599 |
(\<forall>x xa xb. rec_ci g = (x, xa, xb) \<longrightarrow> (\<forall>xc. {\<lambda>nl. nl = xs @ 0 \<up> (xb - xa) @ xc} x {\<lambda>nl. nl = xs @ rec_exec g xs # 0 \<up> (xb - Suc xa) @ xc}))" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
600 |
and ft: "ft = max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
601 |
shows |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
602 |
"{\<lambda>nl. nl = xs @ 0 # 0 \<up> (ft + length gs) @ anything} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
603 |
cn_merge_gs (map rec_ci (take n gs)) ft |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
604 |
{\<lambda>nl. nl = xs @ 0 \<up> (ft - length xs) @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
605 |
map (\<lambda>i. rec_exec i xs) (take n gs) @ 0\<up>(length gs - n) @ 0 \<up> Suc (length xs) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
606 |
using g_cond |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
607 |
proof(induct n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
608 |
case 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
609 |
have "ft > length xs" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
610 |
using ft |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
611 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
612 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
613 |
apply(rule_tac abc_Hoare_haltI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
614 |
apply(rule_tac x = 0 in exI, simp add: abc_steps_l.simps replicate_add[THEN sym] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
615 |
replicate_Suc[THEN sym] del: replicate_Suc) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
616 |
done |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
617 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
618 |
case (Suc n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
619 |
have ind': "\<forall>g\<in>set (take n gs). |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
620 |
terminate g xs \<and> (\<forall>x xa xb. rec_ci g = (x, xa, xb) \<longrightarrow> |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
621 |
(\<forall>xc. {\<lambda>nl. nl = xs @ 0 \<up> (xb - xa) @ xc} x {\<lambda>nl. nl = xs @ rec_exec g xs # 0 \<up> (xb - Suc xa) @ xc})) \<Longrightarrow> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
622 |
{\<lambda>nl. nl = xs @ 0 # 0 \<up> (ft + length gs) @ anything} cn_merge_gs (map rec_ci (take n gs)) ft |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
623 |
{\<lambda>nl. nl = xs @ 0 \<up> (ft - length xs) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 \<up> Suc (length xs) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
624 |
by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
625 |
have g_newcond: "\<forall>g\<in>set (take (Suc n) gs). |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
626 |
terminate g xs \<and> (\<forall>x xa xb. rec_ci g = (x, xa, xb) \<longrightarrow> (\<forall>xc. {\<lambda>nl. nl = xs @ 0 \<up> (xb - xa) @ xc} x {\<lambda>nl. nl = xs @ rec_exec g xs # 0 \<up> (xb - Suc xa) @ xc}))" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
627 |
by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
628 |
from g_newcond have ind: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
629 |
"{\<lambda>nl. nl = xs @ 0 # 0 \<up> (ft + length gs) @ anything} cn_merge_gs (map rec_ci (take n gs)) ft |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
630 |
{\<lambda>nl. nl = xs @ 0 \<up> (ft - length xs) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 \<up> Suc (length xs) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
631 |
apply(rule_tac ind', rule_tac ballI, erule_tac x = g in ballE, simp_all add: take_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
632 |
by(case_tac "n < length gs", simp add:take_Suc_conv_app_nth, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
633 |
show "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
634 |
proof(cases "n < length gs") |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
635 |
case True |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
636 |
have h: "n < length gs" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
637 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
638 |
proof(simp add: take_Suc_conv_app_nth cn_merge_gs_tl_app) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
639 |
obtain gp ga gf where a: "rec_ci (gs!n) = (gp, ga, gf)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
640 |
by (metis prod_cases3) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
641 |
moreover have "min (length gs) n = n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
642 |
using h by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
643 |
moreover have |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
644 |
"{\<lambda>nl. nl = xs @ 0 # 0 \<up> (ft + length gs) @ anything} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
645 |
cn_merge_gs (map rec_ci (take n gs)) ft [+] (gp [+] mv_box ga (ft + n)) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
646 |
{\<lambda>nl. nl = xs @ 0 \<up> (ft - length xs) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
647 |
rec_exec (gs ! n) xs # 0 \<up> (length gs - Suc n) @ 0 # 0 \<up> length xs @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
648 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
649 |
show "{\<lambda>nl. nl = xs @ 0 # 0 \<up> (ft + length gs) @ anything} cn_merge_gs (map rec_ci (take n gs)) ft |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
650 |
{\<lambda>nl. nl = xs @ 0 \<up> (ft - length xs) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 \<up> Suc (length xs) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
651 |
using ind by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
652 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
653 |
have x: "gs!n \<in> set (take (Suc n) gs)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
654 |
using h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
655 |
by(simp add: take_Suc_conv_app_nth) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
656 |
have b: "terminate (gs!n) xs" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
657 |
using a g_newcond h x |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
658 |
by(erule_tac x = "gs!n" in ballE, simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
659 |
hence c: "length xs = ga" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
660 |
using a param_pattern by metis |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
661 |
have d: "gf > ga" using footprint_ge a by simp |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
662 |
have e: "ft \<ge> gf" |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
663 |
using ft a h Max_ge image_eqI |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
664 |
by(simp, rule_tac max.coboundedI2, rule_tac Max_ge, simp, |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
665 |
rule_tac insertI2, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
666 |
rule_tac f = "(\<lambda>(aprog, p, n). n)" and x = "rec_ci (gs!n)" in image_eqI, simp, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
667 |
rule_tac x = "gs!n" in image_eqI, simp, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
668 |
show "{\<lambda>nl. nl = xs @ 0 \<up> (ft - length xs) @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
669 |
map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 \<up> Suc (length xs) @ anything} gp [+] mv_box ga (ft + n) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
670 |
{\<lambda>nl. nl = xs @ 0 \<up> (ft - length xs) @ map (\<lambda>i. rec_exec i xs) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
671 |
(take n gs) @ rec_exec (gs ! n) xs # 0 \<up> (length gs - Suc n) @ 0 # 0 \<up> length xs @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
672 |
proof(rule_tac abc_Hoare_plus_halt) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
673 |
show "{\<lambda>nl. nl = xs @ 0 \<up> (ft - length xs) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 \<up> Suc (length xs) @ anything} gp |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
674 |
{\<lambda>nl. nl = xs @ (rec_exec (gs!n) xs) # 0 \<up> (ft - Suc (length xs)) @ map (\<lambda>i. rec_exec i xs) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
675 |
(take n gs) @ 0 \<up> (length gs - n) @ 0 # 0 \<up> length xs @ anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
676 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
677 |
have |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
678 |
"({\<lambda>nl. nl = xs @ 0 \<up> (gf - ga) @ 0\<up>(ft - gf)@map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 \<up> Suc (length xs) @ anything} |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
679 |
gp {\<lambda>nl. nl = xs @ (rec_exec (gs!n) xs) # 0 \<up> (gf - Suc ga) @ |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
680 |
0\<up>(ft - gf)@map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 \<up> Suc (length xs) @ anything})" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
681 |
using a g_newcond h x |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
682 |
apply(erule_tac x = "gs!n" in ballE) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
683 |
apply(simp, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
684 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
685 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
686 |
using a b c d e |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
687 |
by(simp add: replicate_merge_anywhere) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
688 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
689 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
690 |
show |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
691 |
"{\<lambda>nl. nl = xs @ rec_exec (gs ! n) xs # |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
692 |
0 \<up> (ft - Suc (length xs)) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 # 0 \<up> length xs @ anything} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
693 |
mv_box ga (ft + n) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
694 |
{\<lambda>nl. nl = xs @ 0 \<up> (ft - length xs) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
695 |
rec_exec (gs ! n) xs # 0 \<up> (length gs - Suc n) @ 0 # 0 \<up> length xs @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
696 |
proof - |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
697 |
have "{\<lambda>nl. nl = xs @ rec_exec (gs ! n) xs # 0 \<up> (ft - Suc (length xs)) @ |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
698 |
map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 # 0 \<up> length xs @ anything} |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
699 |
mv_box ga (ft + n) {\<lambda>nl. nl = (xs @ rec_exec (gs ! n) xs # 0 \<up> (ft - Suc (length xs)) @ |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
700 |
map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 # 0 \<up> length xs @ anything) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
701 |
[ft + n := (xs @ rec_exec (gs ! n) xs # 0 \<up> (ft - Suc (length xs)) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
702 |
0 \<up> (length gs - n) @ 0 # 0 \<up> length xs @ anything) ! ga + |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
703 |
(xs @ rec_exec (gs ! n) xs # 0 \<up> (ft - Suc (length xs)) @ |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
704 |
map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 # 0 \<up> length xs @ anything) ! |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
705 |
(ft + n), ga := 0]}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
706 |
using a c d e h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
707 |
apply(rule_tac mv_box_correct) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
708 |
apply(simp, arith, arith) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
709 |
done |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
710 |
moreover have "(xs @ rec_exec (gs ! n) xs # 0 \<up> (ft - Suc (length xs)) @ |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
711 |
map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 # 0 \<up> length xs @ anything) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
712 |
[ft + n := (xs @ rec_exec (gs ! n) xs # 0 \<up> (ft - Suc (length xs)) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
713 |
0 \<up> (length gs - n) @ 0 # 0 \<up> length xs @ anything) ! ga + |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
714 |
(xs @ rec_exec (gs ! n) xs # 0 \<up> (ft - Suc (length xs)) @ |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
715 |
map (\<lambda>i. rec_exec i xs) (take n gs) @ 0 \<up> (length gs - n) @ 0 # 0 \<up> length xs @ anything) ! |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
716 |
(ft + n), ga := 0]= |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
717 |
xs @ 0 \<up> (ft - length xs) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ rec_exec (gs ! n) xs # 0 \<up> (length gs - Suc n) @ 0 # 0 \<up> length xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
718 |
using a c d e h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
719 |
by(simp add: list_update_append nth_append length_replicate split: if_splits del: list_update.simps(2), auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
720 |
ultimately show "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
721 |
by(simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
722 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
723 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
724 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
725 |
ultimately show |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
726 |
"{\<lambda>nl. nl = xs @ 0 # 0 \<up> (ft + length gs) @ anything} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
727 |
cn_merge_gs (map rec_ci (take n gs)) ft [+] (case rec_ci (gs ! n) of (gprog, gpara, gn) \<Rightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
728 |
gprog [+] mv_box gpara (ft + min (length gs) n)) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
729 |
{\<lambda>nl. nl = xs @ 0 \<up> (ft - length xs) @ map (\<lambda>i. rec_exec i xs) (take n gs) @ rec_exec (gs ! n) xs # 0 \<up> (length gs - Suc n) @ 0 # 0 \<up> length xs @ anything}" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
730 |
by simp |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
731 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
732 |
next |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
733 |
case False |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
734 |
have h: "\<not> n < length gs" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
735 |
hence ind': |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
736 |
"{\<lambda>nl. nl = xs @ 0 # 0 \<up> (ft + length gs) @ anything} cn_merge_gs (map rec_ci gs) ft |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
737 |
{\<lambda>nl. nl = xs @ 0 \<up> (ft - length xs) @ map (\<lambda>i. rec_exec i xs) gs @ 0 \<up> Suc (length xs) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
738 |
using ind |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
739 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
740 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
741 |
using h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
742 |
by(simp) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
743 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
744 |
qed |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
745 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
746 |
lemma compile_cn_gs_correct: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
747 |
assumes |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
748 |
g_cond: "\<forall>g\<in>set gs. terminate g xs \<and> |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
749 |
(\<forall>x xa xb. rec_ci g = (x, xa, xb) \<longrightarrow> (\<forall>xc. {\<lambda>nl. nl = xs @ 0 \<up> (xb - xa) @ xc} x {\<lambda>nl. nl = xs @ rec_exec g xs # 0 \<up> (xb - Suc xa) @ xc}))" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
750 |
and ft: "ft = max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
751 |
shows |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
752 |
"{\<lambda>nl. nl = xs @ 0 # 0 \<up> (ft + length gs) @ anything} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
753 |
cn_merge_gs (map rec_ci gs) ft |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
754 |
{\<lambda>nl. nl = xs @ 0 \<up> (ft - length xs) @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
755 |
map (\<lambda>i. rec_exec i xs) gs @ 0 \<up> Suc (length xs) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
756 |
using assms |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
757 |
using compile_cn_gs_correct'[of "length gs" gs xs ft ffp anything ] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
758 |
apply(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
759 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
760 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
761 |
lemma length_mvboxes[simp]: "length (mv_boxes aa ba n) = 3*n" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
762 |
by(induct n, auto simp: mv_boxes.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
763 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
764 |
lemma exp_suc: "a\<up>Suc b = a\<up>b @ [a]" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
765 |
by(simp add: exp_ind del: replicate.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
766 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
767 |
lemma last_0[simp]: |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
768 |
"\<lbrakk>Suc n \<le> ba - aa; length lm2 = Suc n; |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
769 |
length lm3 = ba - Suc (aa + n)\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
770 |
\<Longrightarrow> (last lm2 # lm3 @ butlast lm2 @ 0 # lm4) ! (ba - aa) = (0::nat)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
771 |
proof - |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
772 |
assume h: "Suc n \<le> ba - aa" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
773 |
and g: "length lm2 = Suc n" "length lm3 = ba - Suc (aa + n)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
774 |
from h and g have k: "ba - aa = Suc (length lm3 + n)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
775 |
by arith |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
776 |
from k show |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
777 |
"(last lm2 # lm3 @ butlast lm2 @ 0 # lm4) ! (ba - aa) = 0" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
778 |
apply(simp, insert g) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
779 |
apply(simp add: nth_append) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
780 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
781 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
782 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
783 |
lemma butlast_last[simp]: "length lm1 = aa \<Longrightarrow> |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
784 |
(lm1 @ 0\<up>n @ last lm2 # lm3 @ butlast lm2 @ 0 # lm4) ! (aa + n) = last lm2" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
785 |
apply(simp add: nth_append) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
786 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
787 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
788 |
lemma arith_as_simp[simp]: "\<lbrakk>Suc n \<le> ba - aa; aa < ba\<rbrakk> \<Longrightarrow> |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
789 |
(ba < Suc (aa + (ba - Suc (aa + n) + n))) = False" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
790 |
apply arith |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
791 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
792 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
793 |
lemma butlast_elem[simp]: "\<lbrakk>Suc n \<le> ba - aa; aa < ba; length lm1 = aa; |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
794 |
length lm2 = Suc n; length lm3 = ba - Suc (aa + n)\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
795 |
\<Longrightarrow> (lm1 @ 0\<up>n @ last lm2 # lm3 @ butlast lm2 @ 0 # lm4) ! (ba + n) = 0" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
796 |
using nth_append[of "lm1 @ (0::'a)\<up>n @ last lm2 # lm3 @ butlast lm2" |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
797 |
"(0::'a) # lm4" "ba + n"] |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
798 |
apply(simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
799 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
800 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
801 |
lemma update_butlast_eq0[simp]: |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
802 |
"\<lbrakk>Suc n \<le> ba - aa; aa < ba; length lm1 = aa; length lm2 = Suc n; |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
803 |
length lm3 = ba - Suc (aa + n)\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
804 |
\<Longrightarrow> (lm1 @ 0\<up>n @ last lm2 # lm3 @ butlast lm2 @ (0::nat) # lm4) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
805 |
[ba + n := last lm2, aa + n := 0] = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
806 |
lm1 @ 0 # 0\<up>n @ lm3 @ lm2 @ lm4" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
807 |
using list_update_append[of "lm1 @ 0\<up>n @ last lm2 # lm3 @ butlast lm2" "0 # lm4" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
808 |
"ba + n" "last lm2"] |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
809 |
apply(simp add: list_update_append list_update.simps(2-) replicate_Suc_iff_anywhere exp_suc |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
810 |
del: replicate_Suc) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
811 |
apply(case_tac lm2, simp, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
812 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
813 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
814 |
lemma update_butlast_eq1[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
815 |
"\<lbrakk>Suc (length lm1 + n) \<le> ba; length lm2 = Suc n; length lm3 = ba - Suc (length lm1 + n); |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
816 |
\<not> ba - Suc (length lm1) < ba - Suc (length lm1 + n); \<not> ba + n - length lm1 < n\<rbrakk> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
817 |
\<Longrightarrow> (0::nat) \<up> n @ (last lm2 # lm3 @ butlast lm2 @ 0 # lm4)[ba - length lm1 := last lm2, 0 := 0] = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
818 |
0 # 0 \<up> n @ lm3 @ lm2 @ lm4" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
819 |
apply(subgoal_tac "ba - length lm1 = Suc n + length lm3", simp add: list_update.simps(2-) list_update_append) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
820 |
apply(simp add: replicate_Suc_iff_anywhere exp_suc del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
821 |
apply(case_tac lm2, simp, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
822 |
apply(auto) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
823 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
824 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
825 |
lemma mv_boxes_correct: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
826 |
"\<lbrakk>aa + n \<le> ba; ba > aa; length lm1 = aa; length lm2 = n; length lm3 = ba - aa - n\<rbrakk> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
827 |
\<Longrightarrow> {\<lambda> nl. nl = lm1 @ lm2 @ lm3 @ 0\<up>n @ lm4} (mv_boxes aa ba n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
828 |
{\<lambda> nl. nl = lm1 @ 0\<up>n @ lm3 @ lm2 @ lm4}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
829 |
proof(induct n arbitrary: lm2 lm3 lm4) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
830 |
case 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
831 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
832 |
by(simp add: mv_boxes.simps abc_Hoare_halt_def, rule_tac x = 0 in exI, simp add: abc_steps_l.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
833 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
834 |
case (Suc n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
835 |
have ind: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
836 |
"\<And>lm2 lm3 lm4. |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
837 |
\<lbrakk>aa + n \<le> ba; aa < ba; length lm1 = aa; length lm2 = n; length lm3 = ba - aa - n\<rbrakk> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
838 |
\<Longrightarrow> {\<lambda>nl. nl = lm1 @ lm2 @ lm3 @ 0 \<up> n @ lm4} mv_boxes aa ba n {\<lambda>nl. nl = lm1 @ 0 \<up> n @ lm3 @ lm2 @ lm4}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
839 |
by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
840 |
have h1: "aa + Suc n \<le> ba" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
841 |
have h2: "aa < ba" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
842 |
have h3: "length lm1 = aa" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
843 |
have h4: "length lm2 = Suc n" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
844 |
have h5: "length lm3 = ba - aa - Suc n" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
845 |
have "{\<lambda>nl. nl = lm1 @ lm2 @ lm3 @ 0 \<up> Suc n @ lm4} mv_boxes aa ba n [+] mv_box (aa + n) (ba + n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
846 |
{\<lambda>nl. nl = lm1 @ 0 \<up> Suc n @ lm3 @ lm2 @ lm4}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
847 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
848 |
have "{\<lambda>nl. nl = lm1 @ butlast lm2 @ (last lm2 # lm3) @ 0 \<up> n @ (0 # lm4)} mv_boxes aa ba n |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
849 |
{\<lambda> nl. nl = lm1 @ 0\<up>n @ (last lm2 # lm3) @ butlast lm2 @ (0 # lm4)}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
850 |
using h1 h2 h3 h4 h5 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
851 |
by(rule_tac ind, simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
852 |
moreover have " lm1 @ butlast lm2 @ (last lm2 # lm3) @ 0 \<up> n @ (0 # lm4) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
853 |
= lm1 @ lm2 @ lm3 @ 0 \<up> Suc n @ lm4" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
854 |
using h4 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
855 |
by(simp add: replicate_Suc[THEN sym] exp_suc del: replicate_Suc, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
856 |
case_tac lm2, simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
857 |
ultimately show "{\<lambda>nl. nl = lm1 @ lm2 @ lm3 @ 0 \<up> Suc n @ lm4} mv_boxes aa ba n |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
858 |
{\<lambda> nl. nl = lm1 @ 0\<up>n @ last lm2 # lm3 @ butlast lm2 @ 0 # lm4}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
859 |
by (metis append_Cons) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
860 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
861 |
let ?lm = "lm1 @ 0 \<up> n @ last lm2 # lm3 @ butlast lm2 @ 0 # lm4" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
862 |
have "{\<lambda>nl. nl = ?lm} mv_box (aa + n) (ba + n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
863 |
{\<lambda> nl. nl = ?lm[(ba + n) := ?lm!(aa+n) + ?lm!(ba+n), (aa+n):=0]}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
864 |
using h1 h2 h3 h4 h5 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
865 |
by(rule_tac mv_box_correct, simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
866 |
moreover have "?lm[(ba + n) := ?lm!(aa+n) + ?lm!(ba+n), (aa+n):=0] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
867 |
= lm1 @ 0 \<up> Suc n @ lm3 @ lm2 @ lm4" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
868 |
using h1 h2 h3 h4 h5 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
869 |
by(auto simp: nth_append list_update_append split: if_splits) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
870 |
ultimately show "{\<lambda>nl. nl = lm1 @ 0 \<up> n @ last lm2 # lm3 @ butlast lm2 @ 0 # lm4} mv_box (aa + n) (ba + n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
871 |
{\<lambda>nl. nl = lm1 @ 0 \<up> Suc n @ lm3 @ lm2 @ lm4}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
872 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
873 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
874 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
875 |
by(simp add: mv_boxes.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
876 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
877 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
878 |
lemma update_butlast_eq2[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
879 |
"\<lbrakk>Suc n \<le> aa - length lm1; length lm1 < aa; |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
880 |
length lm2 = aa - Suc (length lm1 + n); |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
881 |
length lm3 = Suc n; |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
882 |
\<not> aa - Suc (length lm1) < aa - Suc (length lm1 + n); |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
883 |
\<not> aa + n - length lm1 < n\<rbrakk> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
884 |
\<Longrightarrow> butlast lm3 @ ((0::nat) # lm2 @ 0 \<up> n @ last lm3 # lm4)[0 := last lm3, aa - length lm1 := 0] = lm3 @ lm2 @ 0 # 0 \<up> n @ lm4" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
885 |
apply(subgoal_tac "aa - length lm1 = length lm2 + Suc n") |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
886 |
apply(simp add: list_update.simps list_update_append) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
887 |
apply(simp add: replicate_Suc[THEN sym] exp_suc del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
888 |
apply(case_tac lm3, simp, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
889 |
apply(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
890 |
done |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
891 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
892 |
lemma mv_boxes_correct2: |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
893 |
"\<lbrakk>n \<le> aa - ba; |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
894 |
ba < aa; |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
895 |
length (lm1::nat list) = ba; |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
896 |
length (lm2::nat list) = aa - ba - n; |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
897 |
length (lm3::nat list) = n\<rbrakk> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
898 |
\<Longrightarrow>{\<lambda> nl. nl = lm1 @ 0\<up>n @ lm2 @ lm3 @ lm4} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
899 |
(mv_boxes aa ba n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
900 |
{\<lambda> nl. nl = lm1 @ lm3 @ lm2 @ 0\<up>n @ lm4}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
901 |
proof(induct n arbitrary: lm2 lm3 lm4) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
902 |
case 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
903 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
904 |
by(simp add: mv_boxes.simps abc_Hoare_halt_def, rule_tac x = 0 in exI, simp add: abc_steps_l.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
905 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
906 |
case (Suc n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
907 |
have ind: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
908 |
"\<And>lm2 lm3 lm4. |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
909 |
\<lbrakk>n \<le> aa - ba; ba < aa; length lm1 = ba; length lm2 = aa - ba - n; length lm3 = n\<rbrakk> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
910 |
\<Longrightarrow> {\<lambda>nl. nl = lm1 @ 0 \<up> n @ lm2 @ lm3 @ lm4} mv_boxes aa ba n {\<lambda>nl. nl = lm1 @ lm3 @ lm2 @ 0 \<up> n @ lm4}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
911 |
by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
912 |
have h1: "Suc n \<le> aa - ba" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
913 |
have h2: "ba < aa" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
914 |
have h3: "length lm1 = ba" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
915 |
have h4: "length lm2 = aa - ba - Suc n" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
916 |
have h5: "length lm3 = Suc n" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
917 |
have "{\<lambda>nl. nl = lm1 @ 0 \<up> Suc n @ lm2 @ lm3 @ lm4} mv_boxes aa ba n [+] mv_box (aa + n) (ba + n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
918 |
{\<lambda>nl. nl = lm1 @ lm3 @ lm2 @ 0 \<up> Suc n @ lm4}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
919 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
920 |
have "{\<lambda> nl. nl = lm1 @ 0 \<up> n @ (0 # lm2) @ (butlast lm3) @ (last lm3 # lm4)} mv_boxes aa ba n |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
921 |
{\<lambda> nl. nl = lm1 @ butlast lm3 @ (0 # lm2) @ 0\<up>n @ (last lm3 # lm4)}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
922 |
using h1 h2 h3 h4 h5 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
923 |
by(rule_tac ind, simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
924 |
moreover have "lm1 @ 0 \<up> n @ (0 # lm2) @ (butlast lm3) @ (last lm3 # lm4) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
925 |
= lm1 @ 0 \<up> Suc n @ lm2 @ lm3 @ lm4" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
926 |
using h5 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
927 |
by(simp add: replicate_Suc_iff_anywhere exp_suc |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
928 |
del: replicate_Suc, case_tac lm3, simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
929 |
ultimately show "{\<lambda>nl. nl = lm1 @ 0 \<up> Suc n @ lm2 @ lm3 @ lm4} mv_boxes aa ba n |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
930 |
{\<lambda> nl. nl = lm1 @ butlast lm3 @ (0 # lm2) @ 0\<up>n @ (last lm3 # lm4)}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
931 |
by metis |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
932 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
933 |
thm mv_box_correct |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
934 |
let ?lm = "lm1 @ butlast lm3 @ (0 # lm2) @ 0 \<up> n @ last lm3 # lm4" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
935 |
have "{\<lambda>nl. nl = ?lm} mv_box (aa + n) (ba + n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
936 |
{\<lambda>nl. nl = ?lm[ba+n := ?lm!(aa+n)+?lm!(ba+n), (aa+n):=0]}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
937 |
using h1 h2 h3 h4 h5 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
938 |
by(rule_tac mv_box_correct, simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
939 |
moreover have "?lm[ba+n := ?lm!(aa+n)+?lm!(ba+n), (aa+n):=0] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
940 |
= lm1 @ lm3 @ lm2 @ 0 \<up> Suc n @ lm4" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
941 |
using h1 h2 h3 h4 h5 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
942 |
by(auto simp: nth_append list_update_append split: if_splits) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
943 |
ultimately show "{\<lambda>nl. nl = lm1 @ butlast lm3 @ (0 # lm2) @ 0 \<up> n @ last lm3 # lm4} mv_box (aa + n) (ba + n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
944 |
{\<lambda>nl. nl = lm1 @ lm3 @ lm2 @ 0 \<up> Suc n @ lm4}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
945 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
946 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
947 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
948 |
by(simp add: mv_boxes.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
949 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
950 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
951 |
lemma save_paras: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
952 |
"{\<lambda>nl. nl = xs @ 0 \<up> (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) - length xs) @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
953 |
map (\<lambda>i. rec_exec i xs) gs @ 0 \<up> Suc (length xs) @ anything} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
954 |
mv_boxes 0 (Suc (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) + length gs)) (length xs) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
955 |
{\<lambda>nl. nl = 0 \<up> max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) @ map (\<lambda>i. rec_exec i xs) gs @ 0 # xs @ anything}" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
956 |
proof - |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
957 |
let ?ft = "max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
958 |
have "{\<lambda>nl. nl = [] @ xs @ (0\<up>(?ft - length xs) @ map (\<lambda>i. rec_exec i xs) gs @ [0]) @ |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
959 |
0 \<up> (length xs) @ anything} mv_boxes 0 (Suc ?ft + length gs) (length xs) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
960 |
{\<lambda>nl. nl = [] @ 0 \<up> (length xs) @ (0\<up>(?ft - length xs) @ map (\<lambda>i. rec_exec i xs) gs @ [0]) @ xs @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
961 |
by(rule_tac mv_boxes_correct, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
962 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
963 |
by(simp add: replicate_merge_anywhere) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
964 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
965 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
966 |
lemma length_le_max_insert_rec_ci[intro]: |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
967 |
"length gs \<le> ffp \<Longrightarrow> length gs \<le> max x1 (Max (insert ffp (x2 ` x3 ` set gs)))" |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
968 |
apply(rule_tac max.coboundedI2) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
969 |
apply(simp add: Max_ge_iff) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
970 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
971 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
972 |
lemma restore_new_paras: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
973 |
"ffp \<ge> length gs |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
974 |
\<Longrightarrow> {\<lambda>nl. nl = 0 \<up> max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) @ map (\<lambda>i. rec_exec i xs) gs @ 0 # xs @ anything} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
975 |
mv_boxes (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))) 0 (length gs) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
976 |
{\<lambda>nl. nl = map (\<lambda>i. rec_exec i xs) gs @ 0 \<up> max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) @ 0 # xs @ anything}" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
977 |
proof - |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
978 |
let ?ft = "max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
979 |
assume j: "ffp \<ge> length gs" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
980 |
hence "{\<lambda> nl. nl = [] @ 0\<up>length gs @ 0\<up>(?ft - length gs) @ map (\<lambda>i. rec_exec i xs) gs @ ((0 # xs) @ anything)} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
981 |
mv_boxes ?ft 0 (length gs) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
982 |
{\<lambda> nl. nl = [] @ map (\<lambda>i. rec_exec i xs) gs @ 0\<up>(?ft - length gs) @ 0\<up>length gs @ ((0 # xs) @ anything)}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
983 |
by(rule_tac mv_boxes_correct2, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
984 |
moreover have "?ft \<ge> length gs" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
985 |
using j |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
986 |
by(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
987 |
ultimately show "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
988 |
using j |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
989 |
by(simp add: replicate_merge_anywhere le_add_diff_inverse) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
990 |
qed |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
991 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
992 |
lemma le_max_insert[intro]: "ffp \<le> max x0 (Max (insert ffp (x1 ` x2 ` set gs)))" |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
993 |
by (rule max.coboundedI2) auto |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
994 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
995 |
declare max_less_iff_conj[simp del] |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
996 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
997 |
lemma save_rs: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
998 |
"\<lbrakk>far = length gs; |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
999 |
ffp \<le> max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))); |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1000 |
far < ffp\<rbrakk> |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1001 |
\<Longrightarrow> {\<lambda>nl. nl = map (\<lambda>i. rec_exec i xs) gs @ |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1002 |
rec_exec (Cn (length xs) f gs) xs # 0 \<up> max (Suc (length xs)) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1003 |
(Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) @ xs @ anything} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1004 |
mv_box far (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1005 |
{\<lambda>nl. nl = map (\<lambda>i. rec_exec i xs) gs @ |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1006 |
0 \<up> (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) - length gs) @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1007 |
rec_exec (Cn (length xs) f gs) xs # 0 \<up> length gs @ xs @ anything}" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1008 |
proof - |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1009 |
let ?ft = "max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1010 |
thm mv_box_correct |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1011 |
let ?lm= " map (\<lambda>i. rec_exec i xs) gs @ rec_exec (Cn (length xs) f gs) xs # 0 \<up> ?ft @ xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1012 |
assume h: "far = length gs" "ffp \<le> ?ft" "far < ffp" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1013 |
hence "{\<lambda> nl. nl = ?lm} mv_box far ?ft {\<lambda> nl. nl = ?lm[?ft := ?lm!far + ?lm!?ft, far := 0]}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1014 |
apply(rule_tac mv_box_correct) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1015 |
by(case_tac "rec_ci a", auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1016 |
moreover have "?lm[?ft := ?lm!far + ?lm!?ft, far := 0] |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1017 |
= map (\<lambda>i. rec_exec i xs) gs @ |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1018 |
0 \<up> (?ft - length gs) @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1019 |
rec_exec (Cn (length xs) f gs) xs # 0 \<up> length gs @ xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1020 |
using h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1021 |
apply(simp add: nth_append) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1022 |
using list_update_length[of "map (\<lambda>i. rec_exec i xs) gs @ rec_exec (Cn (length xs) f gs) xs # |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1023 |
0 \<up> (?ft - Suc (length gs))" 0 "0 \<up> length gs @ xs @ anything" "rec_exec (Cn (length xs) f gs) xs"] |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1024 |
apply(simp add: replicate_merge_anywhere replicate_Suc_iff_anywhere del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1025 |
by(simp add: list_update_append list_update.simps replicate_Suc_iff_anywhere del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1026 |
ultimately show "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1027 |
by(simp) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1028 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1029 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1030 |
lemma length_empty_boxes[simp]: "length (empty_boxes n) = 2*n" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1031 |
apply(induct n, simp, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1032 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1033 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1034 |
lemma empty_one_box_correct: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1035 |
"{\<lambda>nl. nl = 0 \<up> n @ x # lm} [Dec n 2, Goto 0] {\<lambda>nl. nl = 0 # 0 \<up> n @ lm}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1036 |
proof(induct x) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1037 |
case 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1038 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1039 |
by(simp add: abc_Hoare_halt_def, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1040 |
rule_tac x = 1 in exI, simp add: abc_steps_l.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1041 |
abc_step_l.simps abc_fetch.simps abc_lm_v.simps nth_append abc_lm_s.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1042 |
replicate_Suc[THEN sym] exp_suc del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1043 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1044 |
case (Suc x) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1045 |
have "{\<lambda>nl. nl = 0 \<up> n @ x # lm} [Dec n 2, Goto 0] {\<lambda>nl. nl = 0 # 0 \<up> n @ lm}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1046 |
by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1047 |
then obtain stp where "abc_steps_l (0, 0 \<up> n @ x # lm) [Dec n 2, Goto 0] stp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1048 |
= (Suc (Suc 0), 0 # 0 \<up> n @ lm)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1049 |
apply(auto simp: abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1050 |
by(case_tac "abc_steps_l (0, 0 \<up> n @ x # lm) [Dec n 2, Goto 0] na", simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1051 |
moreover have "abc_steps_l (0, 0\<up>n @ Suc x # lm) [Dec n 2, Goto 0] (Suc (Suc 0)) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1052 |
= (0, 0 \<up> n @ x # lm)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1053 |
by(auto simp: abc_steps_l.simps abc_step_l.simps abc_fetch.simps abc_lm_v.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1054 |
nth_append abc_lm_s.simps list_update.simps list_update_append) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1055 |
ultimately have "abc_steps_l (0, 0\<up>n @ Suc x # lm) [Dec n 2, Goto 0] (Suc (Suc 0) + stp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1056 |
= (Suc (Suc 0), 0 # 0\<up>n @ lm)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1057 |
by(simp only: abc_steps_add) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1058 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1059 |
apply(simp add: abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1060 |
apply(rule_tac x = "Suc (Suc stp)" in exI, simp) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1061 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1062 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1063 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1064 |
lemma empty_boxes_correct: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1065 |
"length lm \<ge> n \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1066 |
{\<lambda> nl. nl = lm} empty_boxes n {\<lambda> nl. nl = 0\<up>n @ drop n lm}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1067 |
proof(induct n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1068 |
case 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1069 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1070 |
by(simp add: empty_boxes.simps abc_Hoare_halt_def, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1071 |
rule_tac x = 0 in exI, simp add: abc_steps_l.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1072 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1073 |
case (Suc n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1074 |
have ind: "n \<le> length lm \<Longrightarrow> {\<lambda>nl. nl = lm} empty_boxes n {\<lambda>nl. nl = 0 \<up> n @ drop n lm}" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1075 |
have h: "Suc n \<le> length lm" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1076 |
have "{\<lambda>nl. nl = lm} empty_boxes n [+] [Dec n 2, Goto 0] {\<lambda>nl. nl = 0 # 0 \<up> n @ drop (Suc n) lm}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1077 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1078 |
show "{\<lambda>nl. nl = lm} empty_boxes n {\<lambda>nl. nl = 0 \<up> n @ drop n lm}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1079 |
using h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1080 |
by(rule_tac ind, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1081 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1082 |
show "{\<lambda>nl. nl = 0 \<up> n @ drop n lm} [Dec n 2, Goto 0] {\<lambda>nl. nl = 0 # 0 \<up> n @ drop (Suc n) lm}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1083 |
using empty_one_box_correct[of n "lm ! n" "drop (Suc n) lm"] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1084 |
using h |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1085 |
by(simp add: Cons_nth_drop_Suc) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1086 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1087 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1088 |
by(simp add: empty_boxes.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1089 |
qed |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1090 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1091 |
lemma insert_dominated[simp]: "length gs \<le> ffp \<Longrightarrow> |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1092 |
length gs + (max xs (Max (insert ffp (x1 ` x2 ` set gs))) - length gs) = |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1093 |
max xs (Max (insert ffp (x1 ` x2 ` set gs)))" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1094 |
apply(rule_tac le_add_diff_inverse) |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1095 |
apply(rule_tac max.coboundedI2) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1096 |
apply(simp add: Max_ge_iff) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1097 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1098 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1099 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1100 |
lemma clean_paras: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1101 |
"ffp \<ge> length gs \<Longrightarrow> |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1102 |
{\<lambda>nl. nl = map (\<lambda>i. rec_exec i xs) gs @ |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1103 |
0 \<up> (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) - length gs) @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1104 |
rec_exec (Cn (length xs) f gs) xs # 0 \<up> length gs @ xs @ anything} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1105 |
empty_boxes (length gs) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1106 |
{\<lambda>nl. nl = 0 \<up> max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1107 |
rec_exec (Cn (length xs) f gs) xs # 0 \<up> length gs @ xs @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1108 |
proof- |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1109 |
let ?ft = "max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1110 |
assume h: "length gs \<le> ffp" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1111 |
let ?lm = "map (\<lambda>i. rec_exec i xs) gs @ 0 \<up> (?ft - length gs) @ |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1112 |
rec_exec (Cn (length xs) f gs) xs # 0 \<up> length gs @ xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1113 |
have "{\<lambda> nl. nl = ?lm} empty_boxes (length gs) {\<lambda> nl. nl = 0\<up>length gs @ drop (length gs) ?lm}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1114 |
by(rule_tac empty_boxes_correct, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1115 |
moreover have "0\<up>length gs @ drop (length gs) ?lm |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1116 |
= 0 \<up> ?ft @ rec_exec (Cn (length xs) f gs) xs # 0 \<up> length gs @ xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1117 |
using h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1118 |
by(simp add: replicate_merge_anywhere) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1119 |
ultimately show "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1120 |
by metis |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1121 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1122 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1123 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1124 |
lemma restore_rs: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1125 |
"{\<lambda>nl. nl = 0 \<up> max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1126 |
rec_exec (Cn (length xs) f gs) xs # 0 \<up> length gs @ xs @ anything} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1127 |
mv_box (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))) (length xs) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1128 |
{\<lambda>nl. nl = 0 \<up> length xs @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1129 |
rec_exec (Cn (length xs) f gs) xs # |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1130 |
0 \<up> (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) - (length xs)) @ |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1131 |
0 \<up> length gs @ xs @ anything}" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1132 |
proof - |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1133 |
let ?ft = "max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1134 |
let ?lm = "0\<up>(length xs) @ 0\<up>(?ft - (length xs)) @ rec_exec (Cn (length xs) f gs) xs # 0 \<up> length gs @ xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1135 |
thm mv_box_correct |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1136 |
have "{\<lambda> nl. nl = ?lm} mv_box ?ft (length xs) {\<lambda> nl. nl = ?lm[length xs := ?lm!?ft + ?lm!(length xs), ?ft := 0]}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1137 |
by(rule_tac mv_box_correct, simp, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1138 |
moreover have "?lm[length xs := ?lm!?ft + ?lm!(length xs), ?ft := 0] |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1139 |
= 0 \<up> length xs @ rec_exec (Cn (length xs) f gs) xs # 0 \<up> (?ft - (length xs)) @ 0 \<up> length gs @ xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1140 |
apply(auto simp: list_update_append nth_append) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1141 |
apply(case_tac ?ft, simp_all add: Suc_diff_le list_update.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1142 |
apply(simp add: exp_suc replicate_Suc[THEN sym] del: replicate_Suc) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1143 |
done |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1144 |
ultimately show "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1145 |
by(simp add: replicate_merge_anywhere) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1146 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1147 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1148 |
lemma restore_orgin_paras: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1149 |
"{\<lambda>nl. nl = 0 \<up> length xs @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1150 |
rec_exec (Cn (length xs) f gs) xs # |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1151 |
0 \<up> (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) - length xs) @ 0 \<up> length gs @ xs @ anything} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1152 |
mv_boxes (Suc (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) + length gs)) 0 (length xs) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1153 |
{\<lambda>nl. nl = xs @ rec_exec (Cn (length xs) f gs) xs # 0 \<up> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1154 |
(max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) + length gs) @ anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1155 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1156 |
let ?ft = "max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1157 |
thm mv_boxes_correct2 |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1158 |
have "{\<lambda> nl. nl = [] @ 0\<up>(length xs) @ (rec_exec (Cn (length xs) f gs) xs # 0 \<up> (?ft - length xs) @ 0 \<up> length gs) @ xs @ anything} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1159 |
mv_boxes (Suc ?ft + length gs) 0 (length xs) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1160 |
{\<lambda> nl. nl = [] @ xs @ (rec_exec (Cn (length xs) f gs) xs # 0 \<up> (?ft - length xs) @ 0 \<up> length gs) @ 0\<up>length xs @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1161 |
by(rule_tac mv_boxes_correct2, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1162 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1163 |
by(simp add: replicate_merge_anywhere) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1164 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1165 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1166 |
lemma compile_cn_correct': |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1167 |
assumes f_ind: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1168 |
"\<And> anything r. rec_exec f (map (\<lambda>g. rec_exec g xs) gs) = rec_exec (Cn (length xs) f gs) xs \<Longrightarrow> |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1169 |
{\<lambda>nl. nl = map (\<lambda>g. rec_exec g xs) gs @ 0 \<up> (ffp - far) @ anything} fap |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1170 |
{\<lambda>nl. nl = map (\<lambda>g. rec_exec g xs) gs @ rec_exec (Cn (length xs) f gs) xs # 0 \<up> (ffp - Suc far) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1171 |
and compile: "rec_ci f = (fap, far, ffp)" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1172 |
and term_f: "terminate f (map (\<lambda>g. rec_exec g xs) gs)" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1173 |
and g_cond: "\<forall>g\<in>set gs. terminate g xs \<and> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1174 |
(\<forall>x xa xb. rec_ci g = (x, xa, xb) \<longrightarrow> |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1175 |
(\<forall>xc. {\<lambda>nl. nl = xs @ 0 \<up> (xb - xa) @ xc} x {\<lambda>nl. nl = xs @ rec_exec g xs # 0 \<up> (xb - Suc xa) @ xc}))" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1176 |
shows |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1177 |
"{\<lambda>nl. nl = xs @ 0 # 0 \<up> (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) + length gs) @ anything} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1178 |
cn_merge_gs (map rec_ci gs) (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))) [+] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1179 |
(mv_boxes 0 (Suc (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) + length gs)) (length xs) [+] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1180 |
(mv_boxes (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))) 0 (length gs) [+] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1181 |
(fap [+] (mv_box far (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))) [+] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1182 |
(empty_boxes (length gs) [+] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1183 |
(mv_box (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))) (length xs) [+] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1184 |
mv_boxes (Suc (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) + length gs)) 0 (length xs))))))) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1185 |
{\<lambda>nl. nl = xs @ rec_exec (Cn (length xs) f gs) xs # |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1186 |
0 \<up> (max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs))) + length gs) @ anything}" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1187 |
proof - |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1188 |
let ?ft = "max (Suc (length xs)) (Max (insert ffp ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1189 |
let ?A = "cn_merge_gs (map rec_ci gs) ?ft" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1190 |
let ?B = "mv_boxes 0 (Suc (?ft+length gs)) (length xs)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1191 |
let ?C = "mv_boxes ?ft 0 (length gs)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1192 |
let ?D = fap |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1193 |
let ?E = "mv_box far ?ft" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1194 |
let ?F = "empty_boxes (length gs)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1195 |
let ?G = "mv_box ?ft (length xs)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1196 |
let ?H = "mv_boxes (Suc (?ft + length gs)) 0 (length xs)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1197 |
let ?P1 = "\<lambda>nl. nl = xs @ 0 # 0 \<up> (?ft + length gs) @ anything" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1198 |
let ?S = "\<lambda>nl. nl = xs @ rec_exec (Cn (length xs) f gs) xs # 0 \<up> (?ft + length gs) @ anything" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1199 |
let ?Q1 = "\<lambda> nl. nl = xs @ 0\<up>(?ft - length xs) @ map (\<lambda> i. rec_exec i xs) gs @ 0\<up>(Suc (length xs)) @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1200 |
show "{?P1} (?A [+] (?B [+] (?C [+] (?D [+] (?E [+] (?F [+] (?G [+] ?H))))))) {?S}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1201 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1202 |
show "{?P1} ?A {?Q1}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1203 |
using g_cond |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1204 |
by(rule_tac compile_cn_gs_correct, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1205 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1206 |
let ?Q2 = "\<lambda>nl. nl = 0 \<up> ?ft @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1207 |
map (\<lambda>i. rec_exec i xs) gs @ 0 # xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1208 |
show "{?Q1} (?B [+] (?C [+] (?D [+] (?E [+] (?F [+] (?G [+] ?H)))))) {?S}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1209 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1210 |
show "{?Q1} ?B {?Q2}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1211 |
by(rule_tac save_paras) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1212 |
next |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1213 |
let ?Q3 = "\<lambda> nl. nl = map (\<lambda>i. rec_exec i xs) gs @ 0\<up>?ft @ 0 # xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1214 |
show "{?Q2} (?C [+] (?D [+] (?E [+] (?F [+] (?G [+] ?H))))) {?S}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1215 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1216 |
have "ffp \<ge> length gs" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1217 |
using compile term_f |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1218 |
apply(subgoal_tac "length gs = far") |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1219 |
apply(drule_tac footprint_ge, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1220 |
by(drule_tac param_pattern, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1221 |
thus "{?Q2} ?C {?Q3}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1222 |
by(erule_tac restore_new_paras) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1223 |
next |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1224 |
let ?Q4 = "\<lambda> nl. nl = map (\<lambda>i. rec_exec i xs) gs @ rec_exec (Cn (length xs) f gs) xs # 0\<up>?ft @ xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1225 |
have a: "far = length gs" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1226 |
using compile term_f |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1227 |
by(drule_tac param_pattern, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1228 |
have b:"?ft \<ge> ffp" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1229 |
by auto |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1230 |
have c: "ffp > far" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1231 |
using compile |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1232 |
by(erule_tac footprint_ge) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1233 |
show "{?Q3} (?D [+] (?E [+] (?F [+] (?G [+] ?H)))) {?S}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1234 |
proof(rule_tac abc_Hoare_plus_halt) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1235 |
have "{\<lambda>nl. nl = map (\<lambda>g. rec_exec g xs) gs @ 0 \<up> (ffp - far) @ 0\<up>(?ft - ffp + far) @ 0 # xs @ anything} fap |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1236 |
{\<lambda>nl. nl = map (\<lambda>g. rec_exec g xs) gs @ rec_exec (Cn (length xs) f gs) xs # |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1237 |
0 \<up> (ffp - Suc far) @ 0\<up>(?ft - ffp + far) @ 0 # xs @ anything}" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1238 |
by(rule_tac f_ind, simp add: rec_exec.simps) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1239 |
thus "{?Q3} fap {?Q4}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1240 |
using a b c |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1241 |
by(simp add: replicate_merge_anywhere, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1242 |
case_tac "?ft", simp_all add: exp_suc del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1243 |
next |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1244 |
let ?Q5 = "\<lambda>nl. nl = map (\<lambda>i. rec_exec i xs) gs @ |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1245 |
0\<up>(?ft - length gs) @ rec_exec (Cn (length xs) f gs) xs # 0\<up>(length gs)@ xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1246 |
show "{?Q4} (?E [+] (?F [+] (?G [+] ?H))) {?S}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1247 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1248 |
from a b c show "{?Q4} ?E {?Q5}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1249 |
by(erule_tac save_rs, simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1250 |
next |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1251 |
let ?Q6 = "\<lambda>nl. nl = 0\<up>?ft @ rec_exec (Cn (length xs) f gs) xs # 0\<up>(length gs)@ xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1252 |
show "{?Q5} (?F [+] (?G [+] ?H)) {?S}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1253 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1254 |
have "length gs \<le> ffp" using a b c |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1255 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1256 |
thus "{?Q5} ?F {?Q6}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1257 |
by(erule_tac clean_paras) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1258 |
next |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1259 |
let ?Q7 = "\<lambda>nl. nl = 0\<up>length xs @ rec_exec (Cn (length xs) f gs) xs # 0\<up>(?ft - (length xs)) @ 0\<up>(length gs)@ xs @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1260 |
show "{?Q6} (?G [+] ?H) {?S}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1261 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1262 |
show "{?Q6} ?G {?Q7}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1263 |
by(rule_tac restore_rs) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1264 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1265 |
show "{?Q7} ?H {?S}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1266 |
by(rule_tac restore_orgin_paras) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1267 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1268 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1269 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1270 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1271 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1272 |
qed |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1273 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1274 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1275 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1276 |
lemma compile_cn_correct: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1277 |
assumes termi_f: "terminate f (map (\<lambda>g. rec_exec g xs) gs)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1278 |
and f_ind: "\<And>ap arity fp anything. |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1279 |
rec_ci f = (ap, arity, fp) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1280 |
\<Longrightarrow> {\<lambda>nl. nl = map (\<lambda>g. rec_exec g xs) gs @ 0 \<up> (fp - arity) @ anything} ap |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1281 |
{\<lambda>nl. nl = map (\<lambda>g. rec_exec g xs) gs @ rec_exec f (map (\<lambda>g. rec_exec g xs) gs) # 0 \<up> (fp - Suc arity) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1282 |
and g_cond: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1283 |
"\<forall>g\<in>set gs. terminate g xs \<and> |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1284 |
(\<forall>x xa xb. rec_ci g = (x, xa, xb) \<longrightarrow> (\<forall>xc. {\<lambda>nl. nl = xs @ 0 \<up> (xb - xa) @ xc} x {\<lambda>nl. nl = xs @ rec_exec g xs # 0 \<up> (xb - Suc xa) @ xc}))" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1285 |
and compile: "rec_ci (Cn n f gs) = (ap, arity, fp)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1286 |
and len: "length xs = n" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1287 |
shows "{\<lambda>nl. nl = xs @ 0 \<up> (fp - arity) @ anything} ap {\<lambda>nl. nl = xs @ rec_exec (Cn n f gs) xs # 0 \<up> (fp - Suc arity) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1288 |
proof(case_tac "rec_ci f") |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1289 |
fix fap far ffp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1290 |
assume h: "rec_ci f = (fap, far, ffp)" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1291 |
then have f_newind: "\<And> anything .{\<lambda>nl. nl = map (\<lambda>g. rec_exec g xs) gs @ 0 \<up> (ffp - far) @ anything} fap |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1292 |
{\<lambda>nl. nl = map (\<lambda>g. rec_exec g xs) gs @ rec_exec f (map (\<lambda>g. rec_exec g xs) gs) # 0 \<up> (ffp - Suc far) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1293 |
by(rule_tac f_ind, simp_all) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1294 |
thus "{\<lambda>nl. nl = xs @ 0 \<up> (fp - arity) @ anything} ap {\<lambda>nl. nl = xs @ rec_exec (Cn n f gs) xs # 0 \<up> (fp - Suc arity) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1295 |
using compile len h termi_f g_cond |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1296 |
apply(auto simp: rec_ci.simps abc_comp_commute) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1297 |
apply(rule_tac compile_cn_correct', simp_all) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1298 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1299 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1300 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1301 |
lemma mv_box_correct_simp[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1302 |
"\<lbrakk>length xs = n; ft = max (n+3) (max fft gft)\<rbrakk> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1303 |
\<Longrightarrow> {\<lambda>nl. nl = xs @ 0 # 0 \<up> (ft - n) @ anything} mv_box n ft |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1304 |
{\<lambda>nl. nl = xs @ 0 # 0 \<up> (ft - n) @ anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1305 |
using mv_box_correct[of n ft "xs @ 0 # 0 \<up> (ft - n) @ anything"] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1306 |
by(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1307 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1308 |
lemma length_under_max[simp]: "length xs < max (length xs + 3) fft" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1309 |
by auto |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1310 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1311 |
lemma save_init_rs: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1312 |
"\<lbrakk>length xs = n; ft = max (n+3) (max fft gft)\<rbrakk> |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1313 |
\<Longrightarrow> {\<lambda>nl. nl = xs @ rec_exec f xs # 0 \<up> (ft - n) @ anything} mv_box n (Suc n) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1314 |
{\<lambda>nl. nl = xs @ 0 # rec_exec f xs # 0 \<up> (ft - Suc n) @ anything}" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1315 |
using mv_box_correct[of n "Suc n" "xs @ rec_exec f xs # 0 \<up> (ft - n) @ anything"] |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1316 |
apply(auto simp: list_update_append list_update.simps nth_append split: if_splits) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1317 |
apply(case_tac "(max (length xs + 3) (max fft gft))", simp_all add: list_update.simps Suc_diff_le) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1318 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1319 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1320 |
lemma less_then_max_plus2[simp]: "n + (2::nat) < max (n + 3) x" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1321 |
by auto |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1322 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1323 |
lemma less_then_max_plus3[simp]: "n < max (n + (3::nat)) x" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1324 |
by auto |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1325 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1326 |
lemma mv_box_max_plus_3_correct[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1327 |
"length xs = n \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1328 |
{\<lambda>nl. nl = xs @ x # 0 \<up> (max (n + (3::nat)) (max fft gft) - n) @ anything} mv_box n (max (n + 3) (max fft gft)) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1329 |
{\<lambda>nl. nl = xs @ 0 \<up> (max (n + 3) (max fft gft) - n) @ x # anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1330 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1331 |
assume h: "length xs = n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1332 |
let ?ft = "max (n+3) (max fft gft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1333 |
let ?lm = "xs @ x # 0\<up>(?ft - Suc n) @ 0 # anything" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1334 |
have g: "?ft > n + 2" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1335 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1336 |
thm mv_box_correct |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1337 |
have a: "{\<lambda> nl. nl = ?lm} mv_box n ?ft {\<lambda> nl. nl = ?lm[?ft := ?lm!n + ?lm!?ft, n := 0]}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1338 |
using h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1339 |
by(rule_tac mv_box_correct, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1340 |
have b:"?lm = xs @ x # 0 \<up> (max (n + 3) (max fft gft) - n) @ anything" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1341 |
by(case_tac ?ft, simp_all add: Suc_diff_le exp_suc del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1342 |
have c: "?lm[?ft := ?lm!n + ?lm!?ft, n := 0] = xs @ 0 \<up> (max (n + 3) (max fft gft) - n) @ x # anything" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1343 |
using h g |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1344 |
apply(auto simp: nth_append list_update_append split: if_splits) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1345 |
using list_update_append[of "x # 0 \<up> (max (length xs + 3) (max fft gft) - Suc (length xs))" "0 # anything" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1346 |
"max (length xs + 3) (max fft gft) - length xs" "x"] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1347 |
apply(auto simp: if_splits) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1348 |
apply(simp add: list_update.simps replicate_Suc[THEN sym] del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1349 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1350 |
from a c show "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1351 |
using h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1352 |
apply(simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1353 |
using b |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1354 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1355 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1356 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1357 |
lemma max_less_suc_suc[simp]: "max n (Suc n) < Suc (Suc (max (n + 3) x + anything - Suc 0))" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1358 |
by arith |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1359 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1360 |
lemma suc_less_plus_3[simp]: "Suc n < max (n + 3) x" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1361 |
by arith |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1362 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1363 |
lemma mv_box_ok_suc_simp[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1364 |
"length xs = n |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1365 |
\<Longrightarrow> {\<lambda>nl. nl = xs @ rec_exec f xs # 0 \<up> (max (n + 3) (max fft gft) - Suc n) @ x # anything} mv_box n (Suc n) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1366 |
{\<lambda>nl. nl = xs @ 0 # rec_exec f xs # 0 \<up> (max (n + 3) (max fft gft) - Suc (Suc n)) @ x # anything}" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1367 |
using mv_box_correct[of n "Suc n" "xs @ rec_exec f xs # 0 \<up> (max (n + 3) (max fft gft) - Suc n) @ x # anything"] |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1368 |
apply(simp add: nth_append list_update_append list_update.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1369 |
apply(case_tac "max (n + 3) (max fft gft)", simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1370 |
apply(case_tac nat, simp_all add: Suc_diff_le list_update.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1371 |
done |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1372 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1373 |
lemma abc_append_frist_steps_eq_pre: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1374 |
assumes notfinal: "abc_notfinal (abc_steps_l (0, lm) A n) A" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1375 |
and notnull: "A \<noteq> []" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1376 |
shows "abc_steps_l (0, lm) (A @ B) n = abc_steps_l (0, lm) A n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1377 |
using notfinal |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1378 |
proof(induct n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1379 |
case 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1380 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1381 |
by(simp add: abc_steps_l.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1382 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1383 |
case (Suc n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1384 |
have ind: "abc_notfinal (abc_steps_l (0, lm) A n) A \<Longrightarrow> abc_steps_l (0, lm) (A @ B) n = abc_steps_l (0, lm) A n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1385 |
by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1386 |
have h: "abc_notfinal (abc_steps_l (0, lm) A (Suc n)) A" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1387 |
then have a: "abc_notfinal (abc_steps_l (0, lm) A n) A" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1388 |
by(simp add: notfinal_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1389 |
then have b: "abc_steps_l (0, lm) (A @ B) n = abc_steps_l (0, lm) A n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1390 |
using ind by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1391 |
obtain s lm' where c: "abc_steps_l (0, lm) A n = (s, lm')" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1392 |
by (metis prod.exhaust) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1393 |
then have d: "s < length A \<and> abc_steps_l (0, lm) (A @ B) n = (s, lm')" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1394 |
using a b by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1395 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1396 |
using c |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1397 |
by(simp add: abc_step_red2 abc_fetch.simps abc_step_l.simps nth_append) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1398 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1399 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1400 |
lemma abc_append_first_step_eq_pre: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1401 |
"st < length A |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1402 |
\<Longrightarrow> abc_step_l (st, lm) (abc_fetch st (A @ B)) = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1403 |
abc_step_l (st, lm) (abc_fetch st A)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1404 |
by(simp add: abc_step_l.simps abc_fetch.simps nth_append) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1405 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1406 |
lemma abc_append_frist_steps_halt_eq': |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1407 |
assumes final: "abc_steps_l (0, lm) A n = (length A, lm')" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1408 |
and notnull: "A \<noteq> []" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1409 |
shows "\<exists> n'. abc_steps_l (0, lm) (A @ B) n' = (length A, lm')" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1410 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1411 |
have "\<exists> n'. abc_notfinal (abc_steps_l (0, lm) A n') A \<and> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1412 |
abc_final (abc_steps_l (0, lm) A (Suc n')) A" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1413 |
using assms |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1414 |
by(rule_tac n = n in abc_before_final, simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1415 |
then obtain na where a: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1416 |
"abc_notfinal (abc_steps_l (0, lm) A na) A \<and> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1417 |
abc_final (abc_steps_l (0, lm) A (Suc na)) A" .. |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1418 |
obtain sa lma where b: "abc_steps_l (0, lm) A na = (sa, lma)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1419 |
by (metis prod.exhaust) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1420 |
then have c: "abc_steps_l (0, lm) (A @ B) na = (sa, lma)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1421 |
using a abc_append_frist_steps_eq_pre[of lm A na B] assms |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1422 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1423 |
have d: "sa < length A" using b a by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1424 |
then have e: "abc_step_l (sa, lma) (abc_fetch sa (A @ B)) = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1425 |
abc_step_l (sa, lma) (abc_fetch sa A)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1426 |
by(rule_tac abc_append_first_step_eq_pre) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1427 |
from a have "abc_steps_l (0, lm) A (Suc na) = (length A, lm')" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1428 |
using final equal_when_halt |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1429 |
by(case_tac "abc_steps_l (0, lm) A (Suc na)" , simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1430 |
then have "abc_steps_l (0, lm) (A @ B) (Suc na) = (length A, lm')" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1431 |
using a b c e |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1432 |
by(simp add: abc_step_red2) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1433 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1434 |
by blast |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1435 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1436 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1437 |
lemma abc_append_frist_steps_halt_eq: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1438 |
assumes final: "abc_steps_l (0, lm) A n = (length A, lm')" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1439 |
shows "\<exists> n'. abc_steps_l (0, lm) (A @ B) n' = (length A, lm')" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1440 |
using final |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1441 |
apply(case_tac "A = []") |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1442 |
apply(rule_tac x = 0 in exI, simp add: abc_steps_l.simps abc_exec_null) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1443 |
apply(rule_tac abc_append_frist_steps_halt_eq', simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1444 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1445 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1446 |
lemma suc_suc_max_simp[simp]: "Suc (Suc (max (xs + 3) fft - Suc (Suc ( xs)))) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1447 |
= max ( xs + 3) fft - ( xs)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1448 |
by arith |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1449 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1450 |
lemma contract_dec_ft_length_plus_7[simp]: "\<lbrakk>ft = max (n + 3) (max fft gft); length xs = n\<rbrakk> \<Longrightarrow> |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1451 |
{\<lambda>nl. nl = xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (ft - Suc (Suc n)) @ Suc y # anything} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1452 |
[Dec ft (length gap + 7)] |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1453 |
{\<lambda>nl. nl = xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (ft - Suc (Suc n)) @ y # anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1454 |
apply(simp add: abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1455 |
apply(rule_tac x = 1 in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1456 |
apply(auto simp: abc_steps_l.simps abc_step_l.simps abc_fetch.simps nth_append abc_lm_v.simps abc_lm_s.simps list_update_append) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1457 |
using list_update_length |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1458 |
[of "(x - Suc y) # rec_exec (Pr (length xs) f g) (xs @ [x - Suc y]) # |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1459 |
0 \<up> (max (length xs + 3) (max fft gft) - Suc (Suc (length xs)))" "Suc y" anything y] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1460 |
apply(simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1461 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1462 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1463 |
lemma adjust_paras': |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1464 |
"length xs = n \<Longrightarrow> {\<lambda>nl. nl = xs @ x # y # anything} [Inc n] [+] [Dec (Suc n) 2, Goto 0] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1465 |
{\<lambda>nl. nl = xs @ Suc x # 0 # anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1466 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1467 |
assume "length xs = n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1468 |
thus "{\<lambda>nl. nl = xs @ x # y # anything} [Inc n] {\<lambda> nl. nl = xs @ Suc x # y # anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1469 |
apply(simp add: abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1470 |
apply(rule_tac x = 1 in exI, simp add: abc_steps_l.simps abc_step_l.simps abc_fetch.simps abc_comp.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1471 |
abc_lm_v.simps abc_lm_s.simps nth_append list_update_append list_update.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1472 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1473 |
next |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1474 |
assume h: "length xs = n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1475 |
thus "{\<lambda>nl. nl = xs @ Suc x # y # anything} [Dec (Suc n) 2, Goto 0] {\<lambda>nl. nl = xs @ Suc x # 0 # anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1476 |
proof(induct y) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1477 |
case 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1478 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1479 |
apply(simp add: abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1480 |
apply(rule_tac x = 1 in exI, simp add: abc_steps_l.simps abc_step_l.simps abc_fetch.simps abc_comp.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1481 |
abc_lm_v.simps abc_lm_s.simps nth_append list_update_append list_update.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1482 |
done |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1483 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1484 |
case (Suc y) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1485 |
have "length xs = n \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1486 |
{\<lambda>nl. nl = xs @ Suc x # y # anything} [Dec (Suc n) 2, Goto 0] {\<lambda>nl. nl = xs @ Suc x # 0 # anything}" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1487 |
then obtain stp where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1488 |
"abc_steps_l (0, xs @ Suc x # y # anything) [Dec (Suc n) 2, Goto 0] stp = (2, xs @ Suc x # 0 # anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1489 |
using h |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1490 |
apply(auto simp: abc_Hoare_halt_def numeral_2_eq_2) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1491 |
by (metis (mono_tags, lifting) abc_final.simps abc_holds_for.elims(2) length_Cons list.size(3)) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1492 |
moreover have "abc_steps_l (0, xs @ Suc x # Suc y # anything) [Dec (Suc n) 2, Goto 0] 2 = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1493 |
(0, xs @ Suc x # y # anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1494 |
using h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1495 |
by(simp add: abc_steps_l.simps numeral_2_eq_2 abc_step_l.simps abc_fetch.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1496 |
abc_lm_v.simps abc_lm_s.simps nth_append list_update_append list_update.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1497 |
ultimately show "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1498 |
apply(simp add: abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1499 |
by(rule_tac x = "2 + stp" in exI, simp only: abc_steps_add, simp) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1500 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1501 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1502 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1503 |
lemma adjust_paras: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1504 |
"length xs = n \<Longrightarrow> {\<lambda>nl. nl = xs @ x # y # anything} [Inc n, Dec (Suc n) 3, Goto (Suc 0)] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1505 |
{\<lambda>nl. nl = xs @ Suc x # 0 # anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1506 |
using adjust_paras'[of xs n x y anything] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1507 |
by(simp add: abc_comp.simps abc_shift.simps numeral_2_eq_2 numeral_3_eq_3) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1508 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1509 |
lemma rec_ci_SucSuc_n[simp]: "\<lbrakk>rec_ci g = (gap, gar, gft); \<forall>y<x. terminate g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])]); |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1510 |
length xs = n; Suc y\<le>x\<rbrakk> \<Longrightarrow> gar = Suc (Suc n)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1511 |
apply(erule_tac x = y in allE, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1512 |
apply(drule_tac param_pattern, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1513 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1514 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1515 |
lemma loop_back': |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1516 |
assumes h: "length A = length gap + 4" "length xs = n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1517 |
and le: "y \<ge> x" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1518 |
shows "\<exists> stp. abc_steps_l (length A, xs @ m # (y - x) # x # anything) (A @ [Dec (Suc (Suc n)) 0, Inc (Suc n), Goto (length gap + 4)]) stp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1519 |
= (length A, xs @ m # y # 0 # anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1520 |
using le |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1521 |
proof(induct x) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1522 |
case 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1523 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1524 |
using h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1525 |
by(rule_tac x = 0 in exI, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1526 |
auto simp: abc_steps_l.simps abc_step_l.simps abc_fetch.simps nth_append abc_lm_s.simps abc_lm_v.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1527 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1528 |
case (Suc x) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1529 |
have "x \<le> y \<Longrightarrow> \<exists>stp. abc_steps_l (length A, xs @ m # (y - x) # x # anything) (A @ [Dec (Suc (Suc n)) 0, Inc (Suc n), Goto (length gap + 4)]) stp = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1530 |
(length A, xs @ m # y # 0 # anything)" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1531 |
moreover have "Suc x \<le> y" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1532 |
moreover then have "\<exists> stp. abc_steps_l (length A, xs @ m # (y - Suc x) # Suc x # anything) (A @ [Dec (Suc (Suc n)) 0, Inc (Suc n), Goto (length gap + 4)]) stp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1533 |
= (length A, xs @ m # (y - x) # x # anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1534 |
using h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1535 |
apply(rule_tac x = 3 in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1536 |
by(simp add: abc_steps_l.simps numeral_3_eq_3 abc_step_l.simps abc_fetch.simps nth_append abc_lm_v.simps abc_lm_s.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1537 |
list_update_append list_update.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1538 |
ultimately show "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1539 |
apply(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1540 |
apply(rule_tac x = "stpa + stp" in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1541 |
by(simp add: abc_steps_add) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1542 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1543 |
|
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1544 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1545 |
lemma loop_back: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1546 |
assumes h: "length A = length gap + 4" "length xs = n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1547 |
shows "\<exists> stp. abc_steps_l (length A, xs @ m # 0 # x # anything) (A @ [Dec (Suc (Suc n)) 0, Inc (Suc n), Goto (length gap + 4)]) stp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1548 |
= (0, xs @ m # x # 0 # anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1549 |
using loop_back'[of A gap xs n x x m anything] assms |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1550 |
apply(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1551 |
apply(rule_tac x = "stp + 1" in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1552 |
apply(simp only: abc_steps_add, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1553 |
apply(simp add: abc_steps_l.simps abc_step_l.simps abc_fetch.simps nth_append abc_lm_v.simps abc_lm_s.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1554 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1555 |
|
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1556 |
lemma rec_exec_pr_0_simps: "rec_exec (Pr n f g) (xs @ [0]) = rec_exec f xs" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1557 |
by(simp add: rec_exec.simps) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1558 |
|
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1559 |
lemma rec_exec_pr_Suc_simps: "rec_exec (Pr n f g) (xs @ [Suc y]) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1560 |
= rec_exec g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])])" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1561 |
apply(induct y) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1562 |
apply(simp add: rec_exec.simps) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1563 |
apply(simp add: rec_exec.simps) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1564 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1565 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1566 |
lemma suc_max_simp[simp]: "Suc (max (n + 3) fft - Suc (Suc (Suc n))) = max (n + 3) fft - Suc (Suc n)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1567 |
by arith |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1568 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1569 |
lemma pr_loop: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1570 |
assumes code: "code = ([Dec (max (n + 3) (max fft gft)) (length gap + 7)] [+] (gap [+] [Inc n, Dec (Suc n) 3, Goto (Suc 0)])) @ |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1571 |
[Dec (Suc (Suc n)) 0, Inc (Suc n), Goto (length gap + 4)]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1572 |
and len: "length xs = n" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1573 |
and g_ind: "\<forall> y<x. (\<forall>anything. {\<lambda>nl. nl = xs @ y # rec_exec (Pr n f g) (xs @ [y]) # 0 \<up> (gft - gar) @ anything} gap |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1574 |
{\<lambda>nl. nl = xs @ y # rec_exec (Pr n f g) (xs @ [y]) # rec_exec g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])]) # 0 \<up> (gft - Suc gar) @ anything})" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1575 |
and compile_g: "rec_ci g = (gap, gar, gft)" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1576 |
and termi_g: "\<forall> y<x. terminate g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])])" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1577 |
and ft: "ft = max (n + 3) (max fft gft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1578 |
and less: "Suc y \<le> x" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1579 |
shows |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1580 |
"\<exists>stp. abc_steps_l (0, xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (ft - Suc (Suc n)) @ Suc y # anything) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1581 |
code stp = (0, xs @ (x - y) # rec_exec (Pr n f g) (xs @ [x - y]) # 0 \<up> (ft - Suc (Suc n)) @ y # anything)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1582 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1583 |
let ?A = "[Dec ft (length gap + 7)]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1584 |
let ?B = "gap" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1585 |
let ?C = "[Inc n, Dec (Suc n) 3, Goto (Suc 0)]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1586 |
let ?D = "[Dec (Suc (Suc n)) 0, Inc (Suc n), Goto (length gap + 4)]" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1587 |
have "\<exists> stp. abc_steps_l (0, xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (ft - Suc (Suc n)) @ Suc y # anything) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1588 |
((?A [+] (?B [+] ?C)) @ ?D) stp = (length (?A [+] (?B [+] ?C)), |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1589 |
xs @ (x - y) # 0 # rec_exec g (xs @ [x - Suc y, rec_exec (Pr n f g) (xs @ [x - Suc y])]) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1590 |
# 0 \<up> (ft - Suc (Suc (Suc n))) @ y # anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1591 |
proof - |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1592 |
have "\<exists> stp. abc_steps_l (0, xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (ft - Suc (Suc n)) @ Suc y # anything) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1593 |
((?A [+] (?B [+] ?C))) stp = (length (?A [+] (?B [+] ?C)), xs @ (x - y) # 0 # |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1594 |
rec_exec g (xs @ [x - Suc y, rec_exec (Pr n f g) (xs @ [x - Suc y])]) # 0 \<up> (ft - Suc (Suc (Suc n))) @ y # anything)" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1595 |
proof - |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1596 |
have "{\<lambda> nl. nl = xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (ft - Suc (Suc n)) @ Suc y # anything} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1597 |
(?A [+] (?B [+] ?C)) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1598 |
{\<lambda> nl. nl = xs @ (x - y) # 0 # |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1599 |
rec_exec g (xs @ [x - Suc y, rec_exec (Pr n f g) (xs @ [x - Suc y])]) # 0 \<up> (ft - Suc (Suc (Suc n))) @ y # anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1600 |
proof(rule_tac abc_Hoare_plus_halt) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1601 |
show "{\<lambda>nl. nl = xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (ft - Suc (Suc n)) @ Suc y # anything} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1602 |
[Dec ft (length gap + 7)] |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1603 |
{\<lambda>nl. nl = xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (ft - Suc (Suc n)) @ y # anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1604 |
using ft len |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1605 |
by(simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1606 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1607 |
show |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1608 |
"{\<lambda>nl. nl = xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (ft - Suc (Suc n)) @ y # anything} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1609 |
?B [+] ?C |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1610 |
{\<lambda>nl. nl = xs @ (x - y) # 0 # rec_exec g (xs @ [x - Suc y, rec_exec (Pr n f g) (xs @ [x - Suc y])]) # 0 \<up> (ft - Suc (Suc (Suc n))) @ y # anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1611 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1612 |
have a: "gar = Suc (Suc n)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1613 |
using compile_g termi_g len less |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1614 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1615 |
have b: "gft > gar" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1616 |
using compile_g |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1617 |
by(erule_tac footprint_ge) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1618 |
show "{\<lambda>nl. nl = xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (ft - Suc (Suc n)) @ y # anything} gap |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1619 |
{\<lambda>nl. nl = xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1620 |
rec_exec g (xs @ [x - Suc y, rec_exec (Pr n f g) (xs @ [x - Suc y])]) # 0 \<up> (ft - Suc (Suc (Suc n))) @ y # anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1621 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1622 |
have |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1623 |
"{\<lambda>nl. nl = xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (gft - gar) @ 0\<up>(ft - gft) @ y # anything} gap |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1624 |
{\<lambda>nl. nl = xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1625 |
rec_exec g (xs @ [(x - Suc y), rec_exec (Pr n f g) (xs @ [x - Suc y])]) # 0 \<up> (gft - Suc gar) @ 0\<up>(ft - gft) @ y # anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1626 |
using g_ind less by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1627 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1628 |
using a b ft |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1629 |
by(simp add: replicate_merge_anywhere numeral_3_eq_3) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1630 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1631 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1632 |
show "{\<lambda>nl. nl = xs @ (x - Suc y) # |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1633 |
rec_exec (Pr n f g) (xs @ [x - Suc y]) # |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1634 |
rec_exec g (xs @ [x - Suc y, rec_exec (Pr n f g) (xs @ [x - Suc y])]) # 0 \<up> (ft - Suc (Suc (Suc n))) @ y # anything} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1635 |
[Inc n, Dec (Suc n) 3, Goto (Suc 0)] |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1636 |
{\<lambda>nl. nl = xs @ (x - y) # 0 # rec_exec g (xs @ [x - Suc y, rec_exec (Pr n f g) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1637 |
(xs @ [x - Suc y])]) # 0 \<up> (ft - Suc (Suc (Suc n))) @ y # anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1638 |
using len less |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1639 |
using adjust_paras[of xs n "x - Suc y" " rec_exec (Pr n f g) (xs @ [x - Suc y])" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1640 |
" rec_exec g (xs @ [x - Suc y, rec_exec (Pr n f g) (xs @ [x - Suc y])]) # |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1641 |
0 \<up> (ft - Suc (Suc (Suc n))) @ y # anything"] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1642 |
by(simp add: Suc_diff_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1643 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1644 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1645 |
thus "?thesis" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1646 |
by(simp add: abc_Hoare_halt_def, auto, rule_tac x = na in exI, case_tac "abc_steps_l (0, xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1647 |
0 \<up> (ft - Suc (Suc n)) @ Suc y # anything) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1648 |
([Dec ft (length gap + 7)] [+] (gap [+] [Inc n, Dec (Suc n) 3, Goto (Suc 0)])) na", simp) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1649 |
qed |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1650 |
then obtain stpa where "abc_steps_l (0, xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (ft - Suc (Suc n)) @ Suc y # anything) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1651 |
((?A [+] (?B [+] ?C))) stpa = (length (?A [+] (?B [+] ?C)), |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1652 |
xs @ (x - y) # 0 # rec_exec g (xs @ [x - Suc y, rec_exec (Pr n f g) (xs @ [x - Suc y])]) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1653 |
# 0 \<up> (ft - Suc (Suc (Suc n))) @ y # anything)" .. |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1654 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1655 |
by(erule_tac abc_append_frist_steps_halt_eq) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1656 |
qed |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1657 |
moreover have |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1658 |
"\<exists> stp. abc_steps_l (length (?A [+] (?B [+] ?C)), |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1659 |
xs @ (x - y) # 0 # rec_exec g (xs @ [x - Suc y, rec_exec (Pr n f g) (xs @ [x - Suc y])]) # 0 \<up> (ft - Suc (Suc (Suc n))) @ y # anything) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1660 |
((?A [+] (?B [+] ?C)) @ ?D) stp = (0, xs @ (x - y) # rec_exec g (xs @ [x - Suc y, rec_exec (Pr n f g) (xs @ [x - Suc y])]) # |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1661 |
0 # 0 \<up> (ft - Suc (Suc (Suc n))) @ y # anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1662 |
using len |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1663 |
by(rule_tac loop_back, simp_all) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1664 |
moreover have "rec_exec g (xs @ [x - Suc y, rec_exec (Pr n f g) (xs @ [x - Suc y])]) = rec_exec (Pr n f g) (xs @ [x - y])" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1665 |
using less |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1666 |
thm rec_exec.simps |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1667 |
apply(case_tac "x - y", simp_all add: rec_exec_pr_Suc_simps) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1668 |
by(subgoal_tac "nat = x - Suc y", simp, arith) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1669 |
ultimately show "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1670 |
using code ft |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1671 |
by(auto, rule_tac x = "stp + stpa" in exI, simp add: abc_steps_add replicate_Suc_iff_anywhere del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1672 |
qed |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1673 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1674 |
lemma abc_lm_s_simp0[simp]: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1675 |
"length xs = n \<Longrightarrow> abc_lm_s (xs @ x # rec_exec (Pr n f g) (xs @ [x]) # 0 \<up> (max (n + 3) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1676 |
(max fft gft) - Suc (Suc n)) @ 0 # anything) (max (n + 3) (max fft gft)) 0 = |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1677 |
xs @ x # rec_exec (Pr n f g) (xs @ [x]) # 0 \<up> (max (n + 3) (max fft gft) - Suc n) @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1678 |
apply(simp add: abc_lm_s.simps) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1679 |
using list_update_length[of "xs @ x # rec_exec (Pr n f g) (xs @ [x]) # 0 \<up> (max (n + 3) (max fft gft) - Suc (Suc n))" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1680 |
0 anything 0] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1681 |
apply(auto simp: Suc_diff_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1682 |
apply(simp add: exp_suc[THEN sym] Suc_diff_Suc del: replicate_Suc) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1683 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1684 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1685 |
lemma index_at_zero_elem[simp]: |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1686 |
"(xs @ x # re # 0 \<up> (max (length xs + 3) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1687 |
(max fft gft) - Suc (Suc (length xs))) @ 0 # anything) ! |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1688 |
max (length xs + 3) (max fft gft) = 0" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1689 |
using nth_append_length[of "xs @ x # re # |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1690 |
0 \<up> (max (length xs + 3) (max fft gft) - Suc (Suc (length xs)))" 0 anything] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1691 |
by(simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1692 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1693 |
lemma pr_loop_correct: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1694 |
assumes less: "y \<le> x" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1695 |
and len: "length xs = n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1696 |
and compile_g: "rec_ci g = (gap, gar, gft)" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1697 |
and termi_g: "\<forall> y<x. terminate g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])])" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1698 |
and g_ind: "\<forall> y<x. (\<forall>anything. {\<lambda>nl. nl = xs @ y # rec_exec (Pr n f g) (xs @ [y]) # 0 \<up> (gft - gar) @ anything} gap |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1699 |
{\<lambda>nl. nl = xs @ y # rec_exec (Pr n f g) (xs @ [y]) # rec_exec g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])]) # 0 \<up> (gft - Suc gar) @ anything})" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1700 |
shows "{\<lambda>nl. nl = xs @ (x - y) # rec_exec (Pr n f g) (xs @ [x - y]) # 0 \<up> (max (n + 3) (max fft gft) - Suc (Suc n)) @ y # anything} |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1701 |
([Dec (max (n + 3) (max fft gft)) (length gap + 7)] [+] (gap [+] [Inc n, Dec (Suc n) 3, Goto (Suc 0)])) @ [Dec (Suc (Suc n)) 0, Inc (Suc n), Goto (length gap + 4)] |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1702 |
{\<lambda>nl. nl = xs @ x # rec_exec (Pr n f g) (xs @ [x]) # 0 \<up> (max (n + 3) (max fft gft) - Suc n) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1703 |
using less |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1704 |
proof(induct y) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1705 |
case 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1706 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1707 |
using len |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1708 |
apply(simp add: abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1709 |
apply(rule_tac x = 1 in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1710 |
by(auto simp: abc_steps_l.simps abc_step_l.simps abc_fetch.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1711 |
nth_append abc_comp.simps abc_shift.simps, simp add: abc_lm_v.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1712 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1713 |
case (Suc y) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1714 |
let ?ft = "max (n + 3) (max fft gft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1715 |
let ?C = "[Dec (max (n + 3) (max fft gft)) (length gap + 7)] [+] (gap [+] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1716 |
[Inc n, Dec (Suc n) 3, Goto (Suc 0)]) @ [Dec (Suc (Suc n)) 0, Inc (Suc n), Goto (length gap + 4)]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1717 |
have ind: "y \<le> x \<Longrightarrow> |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1718 |
{\<lambda>nl. nl = xs @ (x - y) # rec_exec (Pr n f g) (xs @ [x - y]) # 0 \<up> (?ft - Suc (Suc n)) @ y # anything} |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1719 |
?C {\<lambda>nl. nl = xs @ x # rec_exec (Pr n f g) (xs @ [x]) # 0 \<up> (?ft - Suc n) @ anything}" by fact |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1720 |
have less: "Suc y \<le> x" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1721 |
have stp1: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1722 |
"\<exists> stp. abc_steps_l (0, xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (?ft - Suc (Suc n)) @ Suc y # anything) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1723 |
?C stp = (0, xs @ (x - y) # rec_exec (Pr n f g) (xs @ [x - y]) # 0 \<up> (?ft - Suc (Suc n)) @ y # anything)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1724 |
using assms less |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1725 |
by(rule_tac pr_loop, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1726 |
then obtain stp1 where a: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1727 |
"abc_steps_l (0, xs @ (x - Suc y) # rec_exec (Pr n f g) (xs @ [x - Suc y]) # 0 \<up> (?ft - Suc (Suc n)) @ Suc y # anything) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1728 |
?C stp1 = (0, xs @ (x - y) # rec_exec (Pr n f g) (xs @ [x - y]) # 0 \<up> (?ft - Suc (Suc n)) @ y # anything)" .. |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1729 |
moreover have |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1730 |
"\<exists> stp. abc_steps_l (0, xs @ (x - y) # rec_exec (Pr n f g) (xs @ [x - y]) # 0 \<up> (?ft - Suc (Suc n)) @ y # anything) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1731 |
?C stp = (length ?C, xs @ x # rec_exec (Pr n f g) (xs @ [x]) # 0 \<up> (?ft - Suc n) @ anything)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1732 |
using ind less |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1733 |
by(auto simp: abc_Hoare_halt_def, case_tac "abc_steps_l (0, xs @ (x - y) # rec_exec (Pr n f g) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1734 |
(xs @ [x - y]) # 0 \<up> (?ft - Suc (Suc n)) @ y # anything) ?C na", rule_tac x = na in exI, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1735 |
then obtain stp2 where b: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1736 |
"abc_steps_l (0, xs @ (x - y) # rec_exec (Pr n f g) (xs @ [x - y]) # 0 \<up> (?ft - Suc (Suc n)) @ y # anything) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1737 |
?C stp2 = (length ?C, xs @ x # rec_exec (Pr n f g) (xs @ [x]) # 0 \<up> (?ft - Suc n) @ anything)" .. |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1738 |
from a b show "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1739 |
by(simp add: abc_Hoare_halt_def, rule_tac x = "stp1 + stp2" in exI, simp add: abc_steps_add) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1740 |
qed |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1741 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1742 |
lemma compile_pr_correct': |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1743 |
assumes termi_g: "\<forall> y<x. terminate g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])])" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1744 |
and g_ind: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1745 |
"\<forall> y<x. (\<forall>anything. {\<lambda>nl. nl = xs @ y # rec_exec (Pr n f g) (xs @ [y]) # 0 \<up> (gft - gar) @ anything} gap |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1746 |
{\<lambda>nl. nl = xs @ y # rec_exec (Pr n f g) (xs @ [y]) # rec_exec g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])]) # 0 \<up> (gft - Suc gar) @ anything})" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1747 |
and termi_f: "terminate f xs" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1748 |
and f_ind: "\<And> anything. {\<lambda>nl. nl = xs @ 0 \<up> (fft - far) @ anything} fap {\<lambda>nl. nl = xs @ rec_exec f xs # 0 \<up> (fft - Suc far) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1749 |
and len: "length xs = n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1750 |
and compile1: "rec_ci f = (fap, far, fft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1751 |
and compile2: "rec_ci g = (gap, gar, gft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1752 |
shows |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1753 |
"{\<lambda>nl. nl = xs @ x # 0 \<up> (max (n + 3) (max fft gft) - n) @ anything} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1754 |
mv_box n (max (n + 3) (max fft gft)) [+] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1755 |
(fap [+] (mv_box n (Suc n) [+] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1756 |
([Dec (max (n + 3) (max fft gft)) (length gap + 7)] [+] (gap [+] [Inc n, Dec (Suc n) 3, Goto (Suc 0)]) @ |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1757 |
[Dec (Suc (Suc n)) 0, Inc (Suc n), Goto (length gap + 4)]))) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1758 |
{\<lambda>nl. nl = xs @ x # rec_exec (Pr n f g) (xs @ [x]) # 0 \<up> (max (n + 3) (max fft gft) - Suc n) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1759 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1760 |
let ?ft = "max (n+3) (max fft gft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1761 |
let ?A = "mv_box n ?ft" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1762 |
let ?B = "fap" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1763 |
let ?C = "mv_box n (Suc n)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1764 |
let ?D = "[Dec ?ft (length gap + 7)]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1765 |
let ?E = "gap [+] [Inc n, Dec (Suc n) 3, Goto (Suc 0)]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1766 |
let ?F = "[Dec (Suc (Suc n)) 0, Inc (Suc n), Goto (length gap + 4)]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1767 |
let ?P = "\<lambda>nl. nl = xs @ x # 0 \<up> (?ft - n) @ anything" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1768 |
let ?S = "\<lambda>nl. nl = xs @ x # rec_exec (Pr n f g) (xs @ [x]) # 0 \<up> (?ft - Suc n) @ anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1769 |
let ?Q1 = "\<lambda>nl. nl = xs @ 0 \<up> (?ft - n) @ x # anything" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1770 |
show "{?P} (?A [+] (?B [+] (?C [+] (?D [+] ?E @ ?F)))) {?S}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1771 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1772 |
show "{?P} ?A {?Q1}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1773 |
using len by simp |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1774 |
next |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1775 |
let ?Q2 = "\<lambda>nl. nl = xs @ rec_exec f xs # 0 \<up> (?ft - Suc n) @ x # anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1776 |
have a: "?ft \<ge> fft" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1777 |
by arith |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1778 |
have b: "far = n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1779 |
using compile1 termi_f len |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1780 |
by(drule_tac param_pattern, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1781 |
have c: "fft > far" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1782 |
using compile1 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1783 |
by(simp add: footprint_ge) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1784 |
show "{?Q1} (?B [+] (?C [+] (?D [+] ?E @ ?F))) {?S}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1785 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1786 |
have "{\<lambda>nl. nl = xs @ 0 \<up> (fft - far) @ 0\<up>(?ft - fft) @ x # anything} fap |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1787 |
{\<lambda>nl. nl = xs @ rec_exec f xs # 0 \<up> (fft - Suc far) @ 0\<up>(?ft - fft) @ x # anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1788 |
by(rule_tac f_ind) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1789 |
moreover have "fft - far + ?ft - fft = ?ft - far" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1790 |
using a b c by arith |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1791 |
moreover have "fft - Suc n + ?ft - fft = ?ft - Suc n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1792 |
using a b c by arith |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1793 |
ultimately show "{?Q1} ?B {?Q2}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1794 |
using b |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1795 |
by(simp add: replicate_merge_anywhere) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1796 |
next |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1797 |
let ?Q3 = "\<lambda> nl. nl = xs @ 0 # rec_exec f xs # 0\<up>(?ft - Suc (Suc n)) @ x # anything" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1798 |
show "{?Q2} (?C [+] (?D [+] ?E @ ?F)) {?S}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1799 |
proof(rule_tac abc_Hoare_plus_halt) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1800 |
show "{?Q2} (?C) {?Q3}" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1801 |
using mv_box_correct[of n "Suc n" "xs @ rec_exec f xs # 0 \<up> (max (n + 3) (max fft gft) - Suc n) @ x # anything"] |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1802 |
using len |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1803 |
by(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1804 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1805 |
show "{?Q3} (?D [+] ?E @ ?F) {?S}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1806 |
using pr_loop_correct[of x x xs n g gap gar gft f fft anything] assms |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1807 |
by(simp add: rec_exec_pr_0_simps) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1808 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1809 |
qed |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1810 |
qed |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1811 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1812 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1813 |
lemma compile_pr_correct: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1814 |
assumes g_ind: "\<forall>y<x. terminate g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])]) \<and> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1815 |
(\<forall>x xa xb. rec_ci g = (x, xa, xb) \<longrightarrow> |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1816 |
(\<forall>xc. {\<lambda>nl. nl = xs @ y # rec_exec (Pr n f g) (xs @ [y]) # 0 \<up> (xb - xa) @ xc} x |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1817 |
{\<lambda>nl. nl = xs @ y # rec_exec (Pr n f g) (xs @ [y]) # rec_exec g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])]) # 0 \<up> (xb - Suc xa) @ xc}))" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1818 |
and termi_f: "terminate f xs" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1819 |
and f_ind: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1820 |
"\<And>ap arity fp anything. |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1821 |
rec_ci f = (ap, arity, fp) \<Longrightarrow> {\<lambda>nl. nl = xs @ 0 \<up> (fp - arity) @ anything} ap {\<lambda>nl. nl = xs @ rec_exec f xs # 0 \<up> (fp - Suc arity) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1822 |
and len: "length xs = n" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1823 |
and compile: "rec_ci (Pr n f g) = (ap, arity, fp)" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1824 |
shows "{\<lambda>nl. nl = xs @ x # 0 \<up> (fp - arity) @ anything} ap {\<lambda>nl. nl = xs @ x # rec_exec (Pr n f g) (xs @ [x]) # 0 \<up> (fp - Suc arity) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1825 |
proof(case_tac "rec_ci f", case_tac "rec_ci g") |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1826 |
fix fap far fft gap gar gft |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1827 |
assume h: "rec_ci f = (fap, far, fft)" "rec_ci g = (gap, gar, gft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1828 |
have g: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1829 |
"\<forall>y<x. (terminate g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])]) \<and> |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1830 |
(\<forall>anything. {\<lambda>nl. nl = xs @ y # rec_exec (Pr n f g) (xs @ [y]) # 0 \<up> (gft - gar) @ anything} gap |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1831 |
{\<lambda>nl. nl = xs @ y # rec_exec (Pr n f g) (xs @ [y]) # rec_exec g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])]) # 0 \<up> (gft - Suc gar) @ anything}))" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1832 |
using g_ind h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1833 |
by(auto) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1834 |
hence termi_g: "\<forall> y<x. terminate g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])])" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1835 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1836 |
from g have g_newind: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1837 |
"\<forall> y<x. (\<forall>anything. {\<lambda>nl. nl = xs @ y # rec_exec (Pr n f g) (xs @ [y]) # 0 \<up> (gft - gar) @ anything} gap |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1838 |
{\<lambda>nl. nl = xs @ y # rec_exec (Pr n f g) (xs @ [y]) # rec_exec g (xs @ [y, rec_exec (Pr n f g) (xs @ [y])]) # 0 \<up> (gft - Suc gar) @ anything})" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1839 |
by auto |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1840 |
have f_newind: "\<And> anything. {\<lambda>nl. nl = xs @ 0 \<up> (fft - far) @ anything} fap {\<lambda>nl. nl = xs @ rec_exec f xs # 0 \<up> (fft - Suc far) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1841 |
using h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1842 |
by(rule_tac f_ind, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1843 |
show "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1844 |
using termi_f termi_g h compile |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1845 |
apply(simp add: rec_ci.simps abc_comp_commute, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1846 |
using g_newind f_newind len |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1847 |
by(rule_tac compile_pr_correct', simp_all) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1848 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1849 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1850 |
fun mn_ind_inv :: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1851 |
"nat \<times> nat list \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat list \<Rightarrow> nat list \<Rightarrow> bool" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1852 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1853 |
"mn_ind_inv (as, lm') ss x rsx suf_lm lm = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1854 |
(if as = ss then lm' = lm @ x # rsx # suf_lm |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1855 |
else if as = ss + 1 then |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1856 |
\<exists>y. (lm' = lm @ x # y # suf_lm) \<and> y \<le> rsx |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1857 |
else if as = ss + 2 then |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1858 |
\<exists>y. (lm' = lm @ x # y # suf_lm) \<and> y \<le> rsx |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1859 |
else if as = ss + 3 then lm' = lm @ x # 0 # suf_lm |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1860 |
else if as = ss + 4 then lm' = lm @ Suc x # 0 # suf_lm |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1861 |
else if as = 0 then lm' = lm @ Suc x # 0 # suf_lm |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1862 |
else False |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1863 |
)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1864 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1865 |
fun mn_stage1 :: "nat \<times> nat list \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1866 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1867 |
"mn_stage1 (as, lm) ss n = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1868 |
(if as = 0 then 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1869 |
else if as = ss + 4 then 1 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1870 |
else if as = ss + 3 then 2 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1871 |
else if as = ss + 2 \<or> as = ss + 1 then 3 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1872 |
else if as = ss then 4 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1873 |
else 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1874 |
)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1875 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1876 |
fun mn_stage2 :: "nat \<times> nat list \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1877 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1878 |
"mn_stage2 (as, lm) ss n = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1879 |
(if as = ss + 1 \<or> as = ss + 2 then (lm ! (Suc n)) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1880 |
else 0)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1881 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1882 |
fun mn_stage3 :: "nat \<times> nat list \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1883 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1884 |
"mn_stage3 (as, lm) ss n = (if as = ss + 2 then 1 else 0)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1885 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1886 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1887 |
fun mn_measure :: "((nat \<times> nat list) \<times> nat \<times> nat) \<Rightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1888 |
(nat \<times> nat \<times> nat)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1889 |
where |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1890 |
"mn_measure ((as, lm), ss, n) = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1891 |
(mn_stage1 (as, lm) ss n, mn_stage2 (as, lm) ss n, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1892 |
mn_stage3 (as, lm) ss n)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1893 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1894 |
definition mn_LE :: "(((nat \<times> nat list) \<times> nat \<times> nat) \<times> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1895 |
((nat \<times> nat list) \<times> nat \<times> nat)) set" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1896 |
where "mn_LE \<equiv> (inv_image lex_triple mn_measure)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1897 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1898 |
lemma wf_mn_le[intro]: "wf mn_LE" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1899 |
by(auto intro:wf_inv_image wf_lex_triple simp: mn_LE_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1900 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1901 |
declare mn_ind_inv.simps[simp del] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1902 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1903 |
lemma put_in_tape_small_enough0[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1904 |
"0 < rsx \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1905 |
\<exists>y. (xs @ x # rsx # anything)[Suc (length xs) := rsx - Suc 0] = xs @ x # y # anything \<and> y \<le> rsx" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1906 |
apply(rule_tac x = "rsx - 1" in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1907 |
apply(simp add: list_update_append list_update.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1908 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1909 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1910 |
lemma put_in_tape_small_enough1[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1911 |
"\<lbrakk>y \<le> rsx; 0 < y\<rbrakk> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1912 |
\<Longrightarrow> \<exists>ya. (xs @ x # y # anything)[Suc (length xs) := y - Suc 0] = xs @ x # ya # anything \<and> ya \<le> rsx" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1913 |
apply(rule_tac x = "y - 1" in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1914 |
apply(simp add: list_update_append list_update.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1915 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1916 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1917 |
lemma abc_comp_null[simp]: "(A [+] B = []) = (A = [] \<and> B = [])" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1918 |
by(auto simp: abc_comp.simps abc_shift.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1919 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1920 |
lemma rec_ci_not_null[simp]: "(rec_ci f \<noteq> ([], a, b))" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1921 |
apply(case_tac f, auto simp: rec_ci_z_def rec_ci_s_def rec_ci.simps addition.simps rec_ci_id.simps) |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1922 |
apply(case_tac "rec_ci x42", auto simp: mv_box.simps) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1923 |
apply(case_tac "rec_ci x52", case_tac "rec_ci x53", simp) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
1924 |
apply(case_tac "rec_ci x62", simp) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1925 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1926 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1927 |
lemma mn_correct: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1928 |
assumes compile: "rec_ci rf = (fap, far, fft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1929 |
and ge: "0 < rsx" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1930 |
and len: "length xs = arity" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1931 |
and B: "B = [Dec (Suc arity) (length fap + 5), Dec (Suc arity) (length fap + 3), Goto (Suc (length fap)), Inc arity, Goto 0]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1932 |
and f: "f = (\<lambda> stp. (abc_steps_l (length fap, xs @ x # rsx # anything) (fap @ B) stp, (length fap), arity)) " |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1933 |
and P: "P =(\<lambda> ((as, lm), ss, arity). as = 0)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1934 |
and Q: "Q = (\<lambda> ((as, lm), ss, arity). mn_ind_inv (as, lm) (length fap) x rsx anything xs)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1935 |
shows "\<exists> stp. P (f stp) \<and> Q (f stp)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1936 |
proof(rule_tac halt_lemma2) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1937 |
show "wf mn_LE" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1938 |
using wf_mn_le by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1939 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1940 |
show "Q (f 0)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1941 |
by(auto simp: Q f abc_steps_l.simps mn_ind_inv.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1942 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1943 |
have "fap \<noteq> []" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1944 |
using compile by auto |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1945 |
thus "\<not> P (f 0)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1946 |
by(auto simp: f P abc_steps_l.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1947 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1948 |
have "fap \<noteq> []" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1949 |
using compile by auto |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1950 |
then have "\<And> stp. \<lbrakk>\<not> P (f stp); Q (f stp)\<rbrakk> \<Longrightarrow> Q (f (Suc stp)) \<and> (f (Suc stp), f stp) \<in> mn_LE" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1951 |
using ge len |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1952 |
apply(case_tac "(abc_steps_l (length fap, xs @ x # rsx # anything) (fap @ B) stp)") |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1953 |
apply(simp add: abc_step_red2 B f P Q) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1954 |
apply(auto split:if_splits simp add:abc_steps_l.simps mn_ind_inv.simps abc_steps_zero B abc_fetch.simps nth_append) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1955 |
by(auto simp: mn_LE_def lex_triple_def lex_pair_def |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1956 |
abc_step_l.simps abc_steps_l.simps mn_ind_inv.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1957 |
abc_lm_v.simps abc_lm_s.simps nth_append abc_fetch.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1958 |
split: if_splits) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1959 |
thus "\<forall>stp. \<not> P (f stp) \<and> Q (f stp) \<longrightarrow> Q (f (Suc stp)) \<and> (f (Suc stp), f stp) \<in> mn_LE" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1960 |
by(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1961 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1962 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1963 |
lemma abc_Hoare_haltE: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1964 |
"{\<lambda> nl. nl = lm1} p {\<lambda> nl. nl = lm2} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1965 |
\<Longrightarrow> \<exists> stp. abc_steps_l (0, lm1) p stp = (length p, lm2)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1966 |
apply(auto simp: abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1967 |
apply(rule_tac x = n in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1968 |
apply(case_tac "abc_steps_l (0, lm1) p n", auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1969 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1970 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1971 |
lemma mn_loop: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1972 |
assumes B: "B = [Dec (Suc arity) (length fap + 5), Dec (Suc arity) (length fap + 3), Goto (Suc (length fap)), Inc arity, Goto 0]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1973 |
and ft: "ft = max (Suc arity) fft" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1974 |
and len: "length xs = arity" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1975 |
and far: "far = Suc arity" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1976 |
and ind: " (\<forall>xc. ({\<lambda>nl. nl = xs @ x # 0 \<up> (fft - far) @ xc} fap |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1977 |
{\<lambda>nl. nl = xs @ x # rec_exec f (xs @ [x]) # 0 \<up> (fft - Suc far) @ xc}))" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1978 |
and exec_less: "rec_exec f (xs @ [x]) > 0" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1979 |
and compile: "rec_ci f = (fap, far, fft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1980 |
shows "\<exists> stp > 0. abc_steps_l (0, xs @ x # 0 \<up> (ft - Suc arity) @ anything) (fap @ B) stp = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1981 |
(0, xs @ Suc x # 0 \<up> (ft - Suc arity) @ anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1982 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1983 |
have "\<exists> stp. abc_steps_l (0, xs @ x # 0 \<up> (ft - Suc arity) @ anything) (fap @ B) stp = |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1984 |
(length fap, xs @ x # rec_exec f (xs @ [x]) # 0 \<up> (ft - Suc (Suc arity)) @ anything)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1985 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1986 |
have "\<exists> stp. abc_steps_l (0, xs @ x # 0 \<up> (ft - Suc arity) @ anything) fap stp = |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1987 |
(length fap, xs @ x # rec_exec f (xs @ [x]) # 0 \<up> (ft - Suc (Suc arity)) @ anything)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1988 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1989 |
have "{\<lambda>nl. nl = xs @ x # 0 \<up> (fft - far) @ 0\<up>(ft - fft) @ anything} fap |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
1990 |
{\<lambda>nl. nl = xs @ x # rec_exec f (xs @ [x]) # 0 \<up> (fft - Suc far) @ 0\<up>(ft - fft) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1991 |
using ind by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1992 |
moreover have "fft > far" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1993 |
using compile |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1994 |
by(erule_tac footprint_ge) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1995 |
ultimately show "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1996 |
using ft far |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1997 |
apply(drule_tac abc_Hoare_haltE) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1998 |
by(simp add: replicate_merge_anywhere max_absorb2) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
1999 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2000 |
then obtain stp where "abc_steps_l (0, xs @ x # 0 \<up> (ft - Suc arity) @ anything) fap stp = |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2001 |
(length fap, xs @ x # rec_exec f (xs @ [x]) # 0 \<up> (ft - Suc (Suc arity)) @ anything)" .. |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2002 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2003 |
by(erule_tac abc_append_frist_steps_halt_eq) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2004 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2005 |
moreover have |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2006 |
"\<exists> stp > 0. abc_steps_l (length fap, xs @ x # rec_exec f (xs @ [x]) # 0 \<up> (ft - Suc (Suc arity)) @ anything) (fap @ B) stp = |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2007 |
(0, xs @ Suc x # 0 # 0 \<up> (ft - Suc (Suc arity)) @ anything)" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2008 |
using mn_correct[of f fap far fft "rec_exec f (xs @ [x])" xs arity B |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2009 |
"(\<lambda>stp. (abc_steps_l (length fap, xs @ x # rec_exec f (xs @ [x]) # 0 \<up> (ft - Suc (Suc arity)) @ anything) (fap @ B) stp, length fap, arity))" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2010 |
x "0 \<up> (ft - Suc (Suc arity)) @ anything" "(\<lambda>((as, lm), ss, arity). as = 0)" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2011 |
"(\<lambda>((as, lm), ss, aritya). mn_ind_inv (as, lm) (length fap) x (rec_exec f (xs @ [x])) (0 \<up> (ft - Suc (Suc arity)) @ anything) xs) "] |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2012 |
B compile exec_less len |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2013 |
apply(subgoal_tac "fap \<noteq> []", auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2014 |
apply(rule_tac x = stp in exI, auto simp: mn_ind_inv.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2015 |
by(case_tac "stp = 0", simp_all add: abc_steps_l.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2016 |
moreover have "fft > far" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2017 |
using compile |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2018 |
by(erule_tac footprint_ge) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2019 |
ultimately show "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2020 |
using ft far |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2021 |
apply(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2022 |
by(rule_tac x = "stp + stpa" in exI, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2023 |
simp add: abc_steps_add replicate_Suc[THEN sym] diff_Suc_Suc del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2024 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2025 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2026 |
lemma mn_loop_correct': |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2027 |
assumes B: "B = [Dec (Suc arity) (length fap + 5), Dec (Suc arity) (length fap + 3), Goto (Suc (length fap)), Inc arity, Goto 0]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2028 |
and ft: "ft = max (Suc arity) fft" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2029 |
and len: "length xs = arity" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2030 |
and ind_all: "\<forall>i\<le>x. (\<forall>xc. ({\<lambda>nl. nl = xs @ i # 0 \<up> (fft - far) @ xc} fap |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2031 |
{\<lambda>nl. nl = xs @ i # rec_exec f (xs @ [i]) # 0 \<up> (fft - Suc far) @ xc}))" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2032 |
and exec_ge: "\<forall> i\<le>x. rec_exec f (xs @ [i]) > 0" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2033 |
and compile: "rec_ci f = (fap, far, fft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2034 |
and far: "far = Suc arity" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2035 |
shows "\<exists> stp > x. abc_steps_l (0, xs @ 0 # 0 \<up> (ft - Suc arity) @ anything) (fap @ B) stp = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2036 |
(0, xs @ Suc x # 0 \<up> (ft - Suc arity) @ anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2037 |
using ind_all exec_ge |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2038 |
proof(induct x) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2039 |
case 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2040 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2041 |
using assms |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2042 |
by(rule_tac mn_loop, simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2043 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2044 |
case (Suc x) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2045 |
have ind': "\<lbrakk>\<forall>i\<le>x. \<forall>xc. {\<lambda>nl. nl = xs @ i # 0 \<up> (fft - far) @ xc} fap {\<lambda>nl. nl = xs @ i # rec_exec f (xs @ [i]) # 0 \<up> (fft - Suc far) @ xc}; |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2046 |
\<forall>i\<le>x. 0 < rec_exec f (xs @ [i])\<rbrakk> \<Longrightarrow> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2047 |
\<exists>stp > x. abc_steps_l (0, xs @ 0 # 0 \<up> (ft - Suc arity) @ anything) (fap @ B) stp = (0, xs @ Suc x # 0 \<up> (ft - Suc arity) @ anything)" by fact |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2048 |
have exec_ge: "\<forall>i\<le>Suc x. 0 < rec_exec f (xs @ [i])" by fact |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2049 |
have ind_all: "\<forall>i\<le>Suc x. \<forall>xc. {\<lambda>nl. nl = xs @ i # 0 \<up> (fft - far) @ xc} fap |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2050 |
{\<lambda>nl. nl = xs @ i # rec_exec f (xs @ [i]) # 0 \<up> (fft - Suc far) @ xc}" by fact |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2051 |
have ind: "\<exists>stp > x. abc_steps_l (0, xs @ 0 # 0 \<up> (ft - Suc arity) @ anything) (fap @ B) stp = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2052 |
(0, xs @ Suc x # 0 \<up> (ft - Suc arity) @ anything)" using ind' exec_ge ind_all by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2053 |
have stp: "\<exists> stp > 0. abc_steps_l (0, xs @ Suc x # 0 \<up> (ft - Suc arity) @ anything) (fap @ B) stp = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2054 |
(0, xs @ Suc (Suc x) # 0 \<up> (ft - Suc arity) @ anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2055 |
using ind_all exec_ge B ft len far compile |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2056 |
by(rule_tac mn_loop, simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2057 |
from ind stp show "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2058 |
apply(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2059 |
by(rule_tac x = "stp + stpa" in exI, simp add: abc_steps_add) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2060 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2061 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2062 |
lemma mn_loop_correct: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2063 |
assumes B: "B = [Dec (Suc arity) (length fap + 5), Dec (Suc arity) (length fap + 3), Goto (Suc (length fap)), Inc arity, Goto 0]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2064 |
and ft: "ft = max (Suc arity) fft" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2065 |
and len: "length xs = arity" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2066 |
and ind_all: "\<forall>i\<le>x. (\<forall>xc. ({\<lambda>nl. nl = xs @ i # 0 \<up> (fft - far) @ xc} fap |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2067 |
{\<lambda>nl. nl = xs @ i # rec_exec f (xs @ [i]) # 0 \<up> (fft - Suc far) @ xc}))" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2068 |
and exec_ge: "\<forall> i\<le>x. rec_exec f (xs @ [i]) > 0" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2069 |
and compile: "rec_ci f = (fap, far, fft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2070 |
and far: "far = Suc arity" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2071 |
shows "\<exists> stp. abc_steps_l (0, xs @ 0 # 0 \<up> (ft - Suc arity) @ anything) (fap @ B) stp = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2072 |
(0, xs @ Suc x # 0 \<up> (ft - Suc arity) @ anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2073 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2074 |
have "\<exists>stp>x. abc_steps_l (0, xs @ 0 # 0 \<up> (ft - Suc arity) @ anything) (fap @ B) stp = (0, xs @ Suc x # 0 \<up> (ft - Suc arity) @ anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2075 |
using assms |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2076 |
by(rule_tac mn_loop_correct', simp_all) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2077 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2078 |
by(auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2079 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2080 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2081 |
lemma compile_mn_correct': |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2082 |
assumes B: "B = [Dec (Suc arity) (length fap + 5), Dec (Suc arity) (length fap + 3), Goto (Suc (length fap)), Inc arity, Goto 0]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2083 |
and ft: "ft = max (Suc arity) fft" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2084 |
and len: "length xs = arity" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2085 |
and termi_f: "terminate f (xs @ [r])" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2086 |
and f_ind: "\<And>anything. {\<lambda>nl. nl = xs @ r # 0 \<up> (fft - far) @ anything} fap |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2087 |
{\<lambda>nl. nl = xs @ r # 0 # 0 \<up> (fft - Suc far) @ anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2088 |
and ind_all: "\<forall>i < r. (\<forall>xc. ({\<lambda>nl. nl = xs @ i # 0 \<up> (fft - far) @ xc} fap |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2089 |
{\<lambda>nl. nl = xs @ i # rec_exec f (xs @ [i]) # 0 \<up> (fft - Suc far) @ xc}))" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2090 |
and exec_less: "\<forall> i<r. rec_exec f (xs @ [i]) > 0" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2091 |
and exec: "rec_exec f (xs @ [r]) = 0" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2092 |
and compile: "rec_ci f = (fap, far, fft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2093 |
shows "{\<lambda>nl. nl = xs @ 0 \<up> (max (Suc arity) fft - arity) @ anything} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2094 |
fap @ B |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2095 |
{\<lambda>nl. nl = xs @ rec_exec (Mn arity f) xs # 0 \<up> (max (Suc arity) fft - Suc arity) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2096 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2097 |
have a: "far = Suc arity" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2098 |
using len compile termi_f |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2099 |
by(drule_tac param_pattern, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2100 |
have b: "fft > far" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2101 |
using compile |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2102 |
by(erule_tac footprint_ge) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2103 |
have "\<exists> stp. abc_steps_l (0, xs @ 0 # 0 \<up> (ft - Suc arity) @ anything) (fap @ B) stp = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2104 |
(0, xs @ r # 0 \<up> (ft - Suc arity) @ anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2105 |
using assms a |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2106 |
apply(case_tac r, rule_tac x = 0 in exI, simp add: abc_steps_l.simps, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2107 |
by(rule_tac mn_loop_correct, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2108 |
moreover have |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2109 |
"\<exists> stp. abc_steps_l (0, xs @ r # 0 \<up> (ft - Suc arity) @ anything) (fap @ B) stp = |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2110 |
(length fap, xs @ r # rec_exec f (xs @ [r]) # 0 \<up> (ft - Suc (Suc arity)) @ anything)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2111 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2112 |
have "\<exists> stp. abc_steps_l (0, xs @ r # 0 \<up> (ft - Suc arity) @ anything) fap stp = |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2113 |
(length fap, xs @ r # rec_exec f (xs @ [r]) # 0 \<up> (ft - Suc (Suc arity)) @ anything)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2114 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2115 |
have "{\<lambda>nl. nl = xs @ r # 0 \<up> (fft - far) @ 0\<up>(ft - fft) @ anything} fap |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2116 |
{\<lambda>nl. nl = xs @ r # rec_exec f (xs @ [r]) # 0 \<up> (fft - Suc far) @ 0\<up>(ft - fft) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2117 |
using f_ind exec by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2118 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2119 |
using ft a b |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2120 |
apply(drule_tac abc_Hoare_haltE) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2121 |
by(simp add: replicate_merge_anywhere max_absorb2) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2122 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2123 |
then obtain stp where "abc_steps_l (0, xs @ r # 0 \<up> (ft - Suc arity) @ anything) fap stp = |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2124 |
(length fap, xs @ r # rec_exec f (xs @ [r]) # 0 \<up> (ft - Suc (Suc arity)) @ anything)" .. |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2125 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2126 |
by(erule_tac abc_append_frist_steps_halt_eq) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2127 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2128 |
moreover have |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2129 |
"\<exists> stp. abc_steps_l (length fap, xs @ r # rec_exec f (xs @ [r]) # 0 \<up> (ft - Suc (Suc arity)) @ anything) (fap @ B) stp = |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2130 |
(length fap + 5, xs @ r # rec_exec f (xs @ [r]) # 0 \<up> (ft - Suc (Suc arity)) @ anything)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2131 |
using ft a b len B exec |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2132 |
apply(rule_tac x = 1 in exI, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2133 |
by(auto simp: abc_steps_l.simps B abc_step_l.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2134 |
abc_fetch.simps nth_append max_absorb2 abc_lm_v.simps abc_lm_s.simps) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2135 |
moreover have "rec_exec (Mn (length xs) f) xs = r" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2136 |
using exec exec_less |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2137 |
apply(auto simp: rec_exec.simps Least_def) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2138 |
thm the_equality |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2139 |
apply(rule_tac the_equality, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2140 |
apply(metis exec_less less_not_refl3 linorder_not_less) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2141 |
by (metis le_neq_implies_less less_not_refl3) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2142 |
ultimately show "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2143 |
using ft a b len B exec |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2144 |
apply(auto simp: abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2145 |
apply(rule_tac x = "stp + stpa + stpb" in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2146 |
by(simp add: abc_steps_add replicate_Suc_iff_anywhere max_absorb2 Suc_diff_Suc del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2147 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2148 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2149 |
lemma compile_mn_correct: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2150 |
assumes len: "length xs = n" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2151 |
and termi_f: "terminate f (xs @ [r])" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2152 |
and f_ind: "\<And>ap arity fp anything. rec_ci f = (ap, arity, fp) \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2153 |
{\<lambda>nl. nl = xs @ r # 0 \<up> (fp - arity) @ anything} ap {\<lambda>nl. nl = xs @ r # 0 # 0 \<up> (fp - Suc arity) @ anything}" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2154 |
and exec: "rec_exec f (xs @ [r]) = 0" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2155 |
and ind_all: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2156 |
"\<forall>i<r. terminate f (xs @ [i]) \<and> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2157 |
(\<forall>x xa xb. rec_ci f = (x, xa, xb) \<longrightarrow> |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2158 |
(\<forall>xc. {\<lambda>nl. nl = xs @ i # 0 \<up> (xb - xa) @ xc} x {\<lambda>nl. nl = xs @ i # rec_exec f (xs @ [i]) # 0 \<up> (xb - Suc xa) @ xc})) \<and> |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2159 |
0 < rec_exec f (xs @ [i])" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2160 |
and compile: "rec_ci (Mn n f) = (ap, arity, fp)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2161 |
shows "{\<lambda>nl. nl = xs @ 0 \<up> (fp - arity) @ anything} ap |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2162 |
{\<lambda>nl. nl = xs @ rec_exec (Mn n f) xs # 0 \<up> (fp - Suc arity) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2163 |
proof(case_tac "rec_ci f") |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2164 |
fix fap far fft |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2165 |
assume h: "rec_ci f = (fap, far, fft)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2166 |
hence f_newind: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2167 |
"\<And>anything. {\<lambda>nl. nl = xs @ r # 0 \<up> (fft - far) @ anything} fap |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2168 |
{\<lambda>nl. nl = xs @ r # 0 # 0 \<up> (fft - Suc far) @ anything}" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2169 |
by(rule_tac f_ind, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2170 |
have newind_all: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2171 |
"\<forall>i < r. (\<forall>xc. ({\<lambda>nl. nl = xs @ i # 0 \<up> (fft - far) @ xc} fap |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2172 |
{\<lambda>nl. nl = xs @ i # rec_exec f (xs @ [i]) # 0 \<up> (fft - Suc far) @ xc}))" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2173 |
using ind_all h |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2174 |
by(auto) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2175 |
have all_less: "\<forall> i<r. rec_exec f (xs @ [i]) > 0" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2176 |
using ind_all by auto |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2177 |
show "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2178 |
using h compile f_newind newind_all all_less len termi_f exec |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2179 |
apply(auto simp: rec_ci.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2180 |
by(rule_tac compile_mn_correct', auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2181 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2182 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2183 |
lemma recursive_compile_correct: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2184 |
"\<lbrakk>terminate recf args; rec_ci recf = (ap, arity, fp)\<rbrakk> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2185 |
\<Longrightarrow> {\<lambda> nl. nl = args @ 0\<up>(fp - arity) @ anything} ap |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2186 |
{\<lambda> nl. nl = args@ rec_exec recf args # 0\<up>(fp - Suc arity) @ anything}" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2187 |
apply(induct arbitrary: ap arity fp anything r rule: terminate.induct) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2188 |
apply(simp_all add: compile_s_correct compile_z_correct compile_id_correct |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2189 |
compile_cn_correct compile_pr_correct compile_mn_correct) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2190 |
done |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2191 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2192 |
definition dummy_abc :: "nat \<Rightarrow> abc_inst list" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2193 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2194 |
"dummy_abc k = [Inc k, Dec k 0, Goto 3]" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2195 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2196 |
definition abc_list_crsp:: "nat list \<Rightarrow> nat list \<Rightarrow> bool" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2197 |
where |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2198 |
"abc_list_crsp xs ys = (\<exists> n. xs = ys @ 0\<up>n \<or> ys = xs @ 0\<up>n)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2199 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2200 |
lemma abc_list_crsp_simp1[intro]: "abc_list_crsp (lm @ 0\<up>m) lm" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2201 |
by(auto simp: abc_list_crsp_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2202 |
|
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2203 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2204 |
lemma abc_list_crsp_lm_v: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2205 |
"abc_list_crsp lma lmb \<Longrightarrow> abc_lm_v lma n = abc_lm_v lmb n" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2206 |
by(auto simp: abc_list_crsp_def abc_lm_v.simps |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2207 |
nth_append) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2208 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2209 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2210 |
lemma abc_list_crsp_elim: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2211 |
"\<lbrakk>abc_list_crsp lma lmb; \<exists> n. lma = lmb @ 0\<up>n \<or> lmb = lma @ 0\<up>n \<Longrightarrow> P \<rbrakk> \<Longrightarrow> P" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2212 |
by(auto simp: abc_list_crsp_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2213 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2214 |
lemma abc_list_crsp_simp[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2215 |
"\<lbrakk>abc_list_crsp lma lmb; m < length lma; m < length lmb\<rbrakk> \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2216 |
abc_list_crsp (lma[m := n]) (lmb[m := n])" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2217 |
by(auto simp: abc_list_crsp_def list_update_append) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2218 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2219 |
lemma abc_list_crsp_simp2[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2220 |
"\<lbrakk>abc_list_crsp lma lmb; m < length lma; \<not> m < length lmb\<rbrakk> \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2221 |
abc_list_crsp (lma[m := n]) (lmb @ 0 \<up> (m - length lmb) @ [n])" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2222 |
apply(auto simp: abc_list_crsp_def list_update_append) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2223 |
apply(rule_tac x = "na + length lmb - Suc m" in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2224 |
apply(rule_tac disjI1) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2225 |
apply(simp add: upd_conv_take_nth_drop min_absorb1) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2226 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2227 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2228 |
lemma abc_list_crsp_simp3[simp]: |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2229 |
"\<lbrakk>abc_list_crsp lma lmb; \<not> m < length lma; m < length lmb\<rbrakk> \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2230 |
abc_list_crsp (lma @ 0 \<up> (m - length lma) @ [n]) (lmb[m := n])" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2231 |
apply(auto simp: abc_list_crsp_def list_update_append) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2232 |
apply(rule_tac x = "na + length lma - Suc m" in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2233 |
apply(rule_tac disjI2) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2234 |
apply(simp add: upd_conv_take_nth_drop min_absorb1) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2235 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2236 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2237 |
lemma abc_list_crsp_simp4[simp]: "\<lbrakk>abc_list_crsp lma lmb; \<not> m < length lma; \<not> m < length lmb\<rbrakk> \<Longrightarrow> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2238 |
abc_list_crsp (lma @ 0 \<up> (m - length lma) @ [n]) (lmb @ 0 \<up> (m - length lmb) @ [n])" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2239 |
by(auto simp: abc_list_crsp_def list_update_append replicate_merge_anywhere) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2240 |
|
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2241 |
lemma abc_list_crsp_lm_s: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2242 |
"abc_list_crsp lma lmb \<Longrightarrow> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2243 |
abc_list_crsp (abc_lm_s lma m n) (abc_lm_s lmb m n)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2244 |
by(auto simp: abc_lm_s.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2245 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2246 |
lemma abc_list_crsp_step: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2247 |
"\<lbrakk>abc_list_crsp lma lmb; abc_step_l (aa, lma) i = (a, lma'); |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2248 |
abc_step_l (aa, lmb) i = (a', lmb')\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2249 |
\<Longrightarrow> a' = a \<and> abc_list_crsp lma' lmb'" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2250 |
apply(case_tac i, auto simp: abc_step_l.simps |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2251 |
abc_list_crsp_lm_s abc_list_crsp_lm_v Let_def |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2252 |
split: abc_inst.splits if_splits) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2253 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2254 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2255 |
lemma abc_list_crsp_steps: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2256 |
"\<lbrakk>abc_steps_l (0, lm @ 0\<up>m) aprog stp = (a, lm'); aprog \<noteq> []\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2257 |
\<Longrightarrow> \<exists> lma. abc_steps_l (0, lm) aprog stp = (a, lma) \<and> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2258 |
abc_list_crsp lm' lma" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2259 |
apply(induct stp arbitrary: a lm', simp add: abc_steps_l.simps, auto) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2260 |
apply(case_tac "abc_steps_l (0, lm @ 0\<up>m) aprog stp", |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2261 |
simp add: abc_step_red) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2262 |
proof - |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2263 |
fix stp a lm' aa b |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2264 |
assume ind: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2265 |
"\<And>a lm'. aa = a \<and> b = lm' \<Longrightarrow> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2266 |
\<exists>lma. abc_steps_l (0, lm) aprog stp = (a, lma) \<and> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2267 |
abc_list_crsp lm' lma" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2268 |
and h: "abc_step_l (aa, b) (abc_fetch aa aprog) = (a, lm')" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2269 |
"abc_steps_l (0, lm @ 0\<up>m) aprog stp = (aa, b)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2270 |
"aprog \<noteq> []" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2271 |
have "\<exists>lma. abc_steps_l (0, lm) aprog stp = (aa, lma) \<and> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2272 |
abc_list_crsp b lma" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2273 |
apply(rule_tac ind, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2274 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2275 |
from this obtain lma where g2: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2276 |
"abc_steps_l (0, lm) aprog stp = (aa, lma) \<and> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2277 |
abc_list_crsp b lma" .. |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2278 |
hence g3: "abc_steps_l (0, lm) aprog (Suc stp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2279 |
= abc_step_l (aa, lma) (abc_fetch aa aprog)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2280 |
apply(rule_tac abc_step_red, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2281 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2282 |
show "\<exists>lma. abc_steps_l (0, lm) aprog (Suc stp) = (a, lma) \<and> abc_list_crsp lm' lma" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2283 |
using g2 g3 h |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2284 |
apply(auto) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2285 |
apply(case_tac "abc_step_l (aa, b) (abc_fetch aa aprog)", |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2286 |
case_tac "abc_step_l (aa, lma) (abc_fetch aa aprog)", simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2287 |
apply(rule_tac abc_list_crsp_step, auto) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2288 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2289 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2290 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2291 |
lemma list_crsp_simp2: "abc_list_crsp (lm1 @ 0\<up>n) lm2 \<Longrightarrow> abc_list_crsp lm1 lm2" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2292 |
proof(induct n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2293 |
case 0 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2294 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2295 |
by(auto simp: abc_list_crsp_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2296 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2297 |
case (Suc n) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2298 |
have ind: "abc_list_crsp (lm1 @ 0 \<up> n) lm2 \<Longrightarrow> abc_list_crsp lm1 lm2" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2299 |
have h: "abc_list_crsp (lm1 @ 0 \<up> Suc n) lm2" by fact |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2300 |
then have "abc_list_crsp (lm1 @ 0 \<up> n) lm2" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2301 |
apply(auto simp: exp_suc abc_list_crsp_def del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2302 |
apply(case_tac n, simp_all add: exp_suc replicate_Suc[THEN sym] del: replicate_Suc, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2303 |
apply(rule_tac x = 1 in exI, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2304 |
by(rule_tac x = "Suc n" in exI, simp, simp add: exp_suc replicate_Suc[THEN sym] del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2305 |
thus "?case" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2306 |
using ind |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2307 |
by auto |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2308 |
qed |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2309 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2310 |
lemma recursive_compile_correct_norm': |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2311 |
"\<lbrakk>rec_ci f = (ap, arity, ft); |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2312 |
terminate f args\<rbrakk> |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2313 |
\<Longrightarrow> \<exists> stp rl. (abc_steps_l (0, args) ap stp) = (length ap, rl) \<and> abc_list_crsp (args @ [rec_exec f args]) rl" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2314 |
using recursive_compile_correct[of f args ap arity ft "[]"] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2315 |
apply(auto simp: abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2316 |
apply(rule_tac x = n in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2317 |
apply(case_tac "abc_steps_l (0, args @ 0 \<up> (ft - arity)) ap n", auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2318 |
apply(drule_tac abc_list_crsp_steps, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2319 |
apply(rule_tac list_crsp_simp2, auto) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2320 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2321 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2322 |
lemma find_exponent_rec_exec[simp]: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2323 |
assumes a: "args @ [rec_exec f args] = lm @ 0 \<up> n" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2324 |
and b: "length args < length lm" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2325 |
shows "\<exists>m. lm = args @ rec_exec f args # 0 \<up> m" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2326 |
using assms |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2327 |
apply(case_tac n, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2328 |
apply(rule_tac x = 0 in exI, simp) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2329 |
apply(drule_tac length_equal, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2330 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2331 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2332 |
lemma find_exponent_complex[simp]: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2333 |
"\<lbrakk>args @ [rec_exec f args] = lm @ 0 \<up> n; \<not> length args < length lm\<rbrakk> |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2334 |
\<Longrightarrow> \<exists>m. (lm @ 0 \<up> (length args - length lm) @ [Suc 0])[length args := 0] = |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2335 |
args @ rec_exec f args # 0 \<up> m" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2336 |
apply(case_tac n, simp_all add: exp_suc list_update_append list_update.simps del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2337 |
apply(subgoal_tac "length args = Suc (length lm)", simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2338 |
apply(rule_tac x = "Suc (Suc 0)" in exI, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2339 |
apply(drule_tac length_equal, simp, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2340 |
done |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2341 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2342 |
lemma compile_append_dummy_correct: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2343 |
assumes compile: "rec_ci f = (ap, ary, fp)" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2344 |
and termi: "terminate f args" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2345 |
shows "{\<lambda> nl. nl = args} (ap [+] dummy_abc (length args)) {\<lambda> nl. (\<exists> m. nl = args @ rec_exec f args # 0\<up>m)}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2346 |
proof(rule_tac abc_Hoare_plus_halt) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2347 |
show "{\<lambda>nl. nl = args} ap {\<lambda> nl. abc_list_crsp (args @ [rec_exec f args]) nl}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2348 |
using compile termi recursive_compile_correct_norm'[of f ap ary fp args] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2349 |
apply(auto simp: abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2350 |
by(rule_tac x = stp in exI, simp) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2351 |
next |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2352 |
show "{abc_list_crsp (args @ [rec_exec f args])} dummy_abc (length args) |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2353 |
{\<lambda>nl. \<exists>m. nl = args @ rec_exec f args # 0 \<up> m}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2354 |
apply(auto simp: dummy_abc_def abc_Hoare_halt_def) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2355 |
apply(rule_tac x = 3 in exI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2356 |
by(auto simp: abc_steps_l.simps abc_list_crsp_def abc_step_l.simps numeral_3_eq_3 abc_fetch.simps |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2357 |
abc_lm_v.simps nth_append abc_lm_s.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2358 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2359 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2360 |
lemma cn_merge_gs_split: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2361 |
"\<lbrakk>i < length gs; rec_ci (gs!i) = (ga, gb, gc)\<rbrakk> \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2362 |
cn_merge_gs (map rec_ci gs) p = cn_merge_gs (map rec_ci (take i gs)) p [+] (ga [+] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2363 |
mv_box gb (p + i)) [+] cn_merge_gs (map rec_ci (drop (Suc i) gs)) (p + Suc i)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2364 |
apply(induct i arbitrary: gs p, case_tac gs, simp, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2365 |
apply(case_tac gs, simp, case_tac "rec_ci a", |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2366 |
simp add: abc_comp_commute[THEN sym]) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2367 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2368 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2369 |
lemma cn_unhalt_case: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2370 |
assumes compile1: "rec_ci (Cn n f gs) = (ap, ar, ft) \<and> length args = ar" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2371 |
and g: "i < length gs" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2372 |
and compile2: "rec_ci (gs!i) = (gap, gar, gft) \<and> gar = length args" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2373 |
and g_unhalt: "\<And> anything. {\<lambda> nl. nl = args @ 0\<up>(gft - gar) @ anything} gap \<up>" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2374 |
and g_ind: "\<And> apj arj ftj j anything. \<lbrakk>j < i; rec_ci (gs!j) = (apj, arj, ftj)\<rbrakk> |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2375 |
\<Longrightarrow> {\<lambda> nl. nl = args @ 0\<up>(ftj - arj) @ anything} apj {\<lambda> nl. nl = args @ rec_exec (gs!j) args # 0\<up>(ftj - Suc arj) @ anything}" |
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2376 |
and all_termi: "\<forall> j<i. terminate (gs!j) args" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2377 |
shows "{\<lambda> nl. nl = args @ 0\<up>(ft - ar) @ anything} ap \<up>" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2378 |
using compile1 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2379 |
apply(case_tac "rec_ci f", auto simp: rec_ci.simps abc_comp_commute) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2380 |
proof(rule_tac abc_Hoare_plus_unhalt1) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2381 |
fix fap far fft |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2382 |
let ?ft = "max (Suc (length args)) (Max (insert fft ((\<lambda>(aprog, p, n). n) ` rec_ci ` set gs)))" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2383 |
let ?Q = "\<lambda>nl. nl = args @ 0\<up> (?ft - length args) @ map (\<lambda>i. rec_exec i args) (take i gs) @ |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2384 |
0\<up>(length gs - i) @ 0\<up> Suc (length args) @ anything" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2385 |
have "cn_merge_gs (map rec_ci gs) ?ft = |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2386 |
cn_merge_gs (map rec_ci (take i gs)) ?ft [+] (gap [+] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2387 |
mv_box gar (?ft + i)) [+] cn_merge_gs (map rec_ci (drop (Suc i) gs)) (?ft + Suc i)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2388 |
using g compile2 cn_merge_gs_split by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2389 |
thus "{\<lambda>nl. nl = args @ 0 # 0 \<up> (?ft + length gs) @ anything} (cn_merge_gs (map rec_ci gs) ?ft) \<up>" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2390 |
proof(simp, rule_tac abc_Hoare_plus_unhalt1, rule_tac abc_Hoare_plus_unhalt2, |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2391 |
rule_tac abc_Hoare_plus_unhalt1) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2392 |
let ?Q_tmp = "\<lambda>nl. nl = args @ 0\<up> (gft - gar) @ 0\<up>(?ft - (length args) - (gft -gar)) @ map (\<lambda>i. rec_exec i args) (take i gs) @ |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2393 |
0\<up>(length gs - i) @ 0\<up> Suc (length args) @ anything" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2394 |
have a: "{?Q_tmp} gap \<up>" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2395 |
using g_unhalt[of "0 \<up> (?ft - (length args) - (gft - gar)) @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2396 |
map (\<lambda>i. rec_exec i args) (take i gs) @ 0 \<up> (length gs - i) @ 0 \<up> Suc (length args) @ anything"] |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2397 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2398 |
moreover have "?ft \<ge> gft" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2399 |
using g compile2 |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2400 |
apply(rule_tac max.coboundedI2, rule_tac Max_ge, simp, rule_tac insertI2) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2401 |
apply(rule_tac x = "rec_ci (gs ! i)" in image_eqI, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2402 |
by(rule_tac x = "gs!i" in image_eqI, simp, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2403 |
then have b:"?Q_tmp = ?Q" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2404 |
using compile2 |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2405 |
apply(rule_tac arg_cong) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2406 |
by(simp add: replicate_merge_anywhere) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2407 |
thus "{?Q} gap \<up>" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2408 |
using a by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2409 |
next |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2410 |
show "{\<lambda>nl. nl = args @ 0 # 0 \<up> (?ft + length gs) @ anything} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2411 |
cn_merge_gs (map rec_ci (take i gs)) ?ft |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2412 |
{\<lambda>nl. nl = args @ 0 \<up> (?ft - length args) @ |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2413 |
map (\<lambda>i. rec_exec i args) (take i gs) @ 0 \<up> (length gs - i) @ 0 \<up> Suc (length args) @ anything}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2414 |
using all_termi |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2415 |
apply(rule_tac compile_cn_gs_correct', auto simp: set_conv_nth) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2416 |
by(drule_tac apj = x and arj = xa and ftj = xb and j = ia and anything = xc in g_ind, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2417 |
qed |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2418 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2419 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2420 |
|
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2421 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2422 |
lemma mn_unhalt_case': |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2423 |
assumes compile: "rec_ci f = (a, b, c)" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2424 |
and all_termi: "\<forall>i. terminate f (args @ [i]) \<and> 0 < rec_exec f (args @ [i])" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2425 |
and B: "B = [Dec (Suc (length args)) (length a + 5), Dec (Suc (length args)) (length a + 3), |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2426 |
Goto (Suc (length a)), Inc (length args), Goto 0]" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2427 |
shows "{\<lambda>nl. nl = args @ 0 \<up> (max (Suc (length args)) c - length args) @ anything} |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2428 |
a @ B \<up>" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2429 |
proof(rule_tac abc_Hoare_unhaltI, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2430 |
fix n |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2431 |
have a: "b = Suc (length args)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2432 |
using all_termi compile |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2433 |
apply(erule_tac x = 0 in allE) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2434 |
by(auto, drule_tac param_pattern,auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2435 |
moreover have b: "c > b" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2436 |
using compile by(elim footprint_ge) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2437 |
ultimately have c: "max (Suc (length args)) c = c" by arith |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2438 |
have "\<exists> stp > n. abc_steps_l (0, args @ 0 # 0\<up>(c - Suc (length args)) @ anything) (a @ B) stp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2439 |
= (0, args @ Suc n # 0\<up>(c - Suc (length args)) @ anything)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2440 |
using assms a b c |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2441 |
proof(rule_tac mn_loop_correct', auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2442 |
fix i xc |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2443 |
show "{\<lambda>nl. nl = args @ i # 0 \<up> (c - Suc (length args)) @ xc} a |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2444 |
{\<lambda>nl. nl = args @ i # rec_exec f (args @ [i]) # 0 \<up> (c - Suc (Suc (length args))) @ xc}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2445 |
using all_termi recursive_compile_correct[of f "args @ [i]" a b c xc] compile a |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2446 |
by(simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2447 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2448 |
then obtain stp where d: "stp > n \<and> abc_steps_l (0, args @ 0 # 0\<up>(c - Suc (length args)) @ anything) (a @ B) stp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2449 |
= (0, args @ Suc n # 0\<up>(c - Suc (length args)) @ anything)" .. |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2450 |
then obtain d where e: "stp = n + Suc d" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2451 |
by (metis add_Suc_right less_iff_Suc_add) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2452 |
obtain s nl where f: "abc_steps_l (0, args @ 0 # 0\<up>(c - Suc (length args)) @ anything) (a @ B) n = (s, nl)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2453 |
by (metis prod.exhaust) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2454 |
have g: "s < length (a @ B)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2455 |
using d e f |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2456 |
apply(rule_tac classical, simp only: abc_steps_add) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2457 |
by(simp add: halt_steps2 leI) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2458 |
from f g show "abc_notfinal (abc_steps_l (0, args @ 0 \<up> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2459 |
(max (Suc (length args)) c - length args) @ anything) (a @ B) n) (a @ B)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2460 |
using c b a |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2461 |
by(simp add: replicate_Suc_iff_anywhere Suc_diff_Suc del: replicate_Suc) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2462 |
qed |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2463 |
|
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2464 |
lemma mn_unhalt_case: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2465 |
assumes compile: "rec_ci (Mn n f) = (ap, ar, ft) \<and> length args = ar" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2466 |
and all_term: "\<forall> i. terminate f (args @ [i]) \<and> rec_exec f (args @ [i]) > 0" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2467 |
shows "{\<lambda> nl. nl = args @ 0\<up>(ft - ar) @ anything} ap \<up> " |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2468 |
using assms |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2469 |
apply(case_tac "rec_ci f", auto simp: rec_ci.simps abc_comp_commute) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2470 |
by(rule_tac mn_unhalt_case', simp_all) |
129
c3832c4963c4
updated recursive
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
2471 |
|
c3832c4963c4
updated recursive
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
2472 |
fun tm_of_rec :: "recf \<Rightarrow> instr list" |
c3832c4963c4
updated recursive
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
2473 |
where "tm_of_rec recf = (let (ap, k, fp) = rec_ci recf in |
c3832c4963c4
updated recursive
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
2474 |
let tp = tm_of (ap [+] dummy_abc k) in |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2475 |
tp @ (shift (mopup k) (length tp div 2)))" |
129
c3832c4963c4
updated recursive
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
2476 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2477 |
lemma recursive_compile_to_tm_correct1: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2478 |
assumes compile: "rec_ci recf = (ap, ary, fp)" |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2479 |
and termi: " terminate recf args" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2480 |
and tp: "tp = tm_of (ap [+] dummy_abc (length args))" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2481 |
shows "\<exists> stp m l. steps0 (Suc 0, Bk # Bk # ires, <args> @ Bk\<up>rn) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2482 |
(tp @ shift (mopup (length args)) (length tp div 2)) stp = (0, Bk\<up>m @ Bk # Bk # ires, Oc\<up>Suc (rec_exec recf args) @ Bk\<up>l)" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2483 |
proof - |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2484 |
have "{\<lambda>nl. nl = args} ap [+] dummy_abc (length args) {\<lambda>nl. \<exists>m. nl = args @ rec_exec recf args # 0 \<up> m}" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2485 |
using compile termi compile |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2486 |
by(rule_tac compile_append_dummy_correct, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2487 |
then obtain stp m where h: "abc_steps_l (0, args) (ap [+] dummy_abc (length args)) stp = |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2488 |
(length (ap [+] dummy_abc (length args)), args @ rec_exec recf args # 0\<up>m) " |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2489 |
apply(simp add: abc_Hoare_halt_def, auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2490 |
by(case_tac "abc_steps_l (0, args) (ap [+] dummy_abc (length args)) n", auto) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2491 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2492 |
using assms tp |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2493 |
by(rule_tac lm = args and stp = stp and am = "args @ rec_exec recf args # 0 \<up> m" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2494 |
in compile_correct_halt, auto simp: crsp.simps start_of.simps length_abc_comp abc_lm_v.simps) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2495 |
qed |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2496 |
|
126
0b302c0b449a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
70
diff
changeset
|
2497 |
lemma recursive_compile_to_tm_correct2: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2498 |
assumes termi: " terminate recf args" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2499 |
shows "\<exists> stp m l. steps0 (Suc 0, [Bk, Bk], <args>) (tm_of_rec recf) stp = |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2500 |
(0, Bk\<up>Suc (Suc m), Oc\<up>Suc (rec_exec recf args) @ Bk\<up>l)" |
230
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2501 |
proof(case_tac "rec_ci recf", simp add: tm_of_rec.simps) |
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2502 |
fix ap ar fp |
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2503 |
assume "rec_ci recf = (ap, ar, fp)" |
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2504 |
thus "\<exists>stp m l. steps0 (Suc 0, [Bk, Bk], <args>) |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2505 |
(tm_of (ap [+] dummy_abc ar) @ shift (mopup ar) (sum_list (layout_of (ap [+] dummy_abc ar)))) stp = |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2506 |
(0, Bk # Bk # Bk \<up> m, Oc # Oc \<up> rec_exec recf args @ Bk \<up> l)" |
230
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2507 |
using recursive_compile_to_tm_correct1[of recf ap ar fp args "tm_of (ap [+] dummy_abc (length args))" "[]" 0] |
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2508 |
assms param_pattern[of recf args ap ar fp] |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2509 |
by(simp add: replicate_Suc[THEN sym] replicate_Suc_iff_anywhere del: replicate_Suc, |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2510 |
simp add: exp_suc del: replicate_Suc) |
230
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2511 |
qed |
126
0b302c0b449a
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
70
diff
changeset
|
2512 |
|
129
c3832c4963c4
updated recursive
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
2513 |
lemma recursive_compile_to_tm_correct3: |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2514 |
assumes termi: "terminate recf args" |
230
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2515 |
shows "{\<lambda> tp. tp =([Bk, Bk], <args>)} (tm_of_rec recf) |
248
aea02b5a58d2
repaired old files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
240
diff
changeset
|
2516 |
{\<lambda> tp. \<exists> k l. tp = (Bk\<up> k, <rec_exec recf args> @ Bk \<up> l)}" |
230
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2517 |
using recursive_compile_to_tm_correct2[OF assms] |
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2518 |
apply(auto simp add: Hoare_halt_def) |
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2519 |
apply(rule_tac x = stp in exI) |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2520 |
apply(auto simp add: tape_of_nat_def) |
230
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2521 |
apply(rule_tac x = "Suc (Suc m)" in exI) |
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2522 |
apply(simp) |
49dcc0b9b0b3
adapted paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
229
diff
changeset
|
2523 |
done |
129
c3832c4963c4
updated recursive
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
126
diff
changeset
|
2524 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2525 |
lemma list_all_suc_many[simp]: |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2526 |
"list_all (\<lambda>(acn, s). s \<le> Suc (Suc (Suc (Suc (Suc (Suc (2 * n))))))) xs \<Longrightarrow> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2527 |
list_all (\<lambda>(acn, s). s \<le> Suc (Suc (Suc (Suc (Suc (Suc (Suc (Suc (2 * n))))))))) xs" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2528 |
apply(induct xs, simp, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2529 |
apply(case_tac a, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2530 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2531 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2532 |
lemma shift_append: "shift (xs @ ys) n = shift xs n @ shift ys n" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2533 |
apply(simp add: shift.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2534 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2535 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2536 |
lemma length_shift_mopup[simp]: "length (shift (mopup n) ss) = 4 * n + 12" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2537 |
apply(auto simp: mopup.simps shift_append mopup_b_def) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2538 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2539 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2540 |
lemma length_tm_even[intro]: "length (tm_of ap) mod 2 = 0" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2541 |
apply(simp add: tm_of.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2542 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2543 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2544 |
lemma tms_of_at_index[simp]: "k < length ap \<Longrightarrow> tms_of ap ! k = |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2545 |
ci (layout_of ap) (start_of (layout_of ap) k) (ap ! k)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2546 |
apply(simp add: tms_of.simps tpairs_of.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2547 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2548 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2549 |
lemma start_of_suc_inc: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2550 |
"\<lbrakk>k < length ap; ap ! k = Inc n\<rbrakk> \<Longrightarrow> start_of (layout_of ap) (Suc k) = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2551 |
start_of (layout_of ap) k + 2 * n + 9" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2552 |
apply(rule_tac start_of_Suc1, auto simp: abc_fetch.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2553 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2554 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2555 |
lemma start_of_suc_dec: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2556 |
"\<lbrakk>k < length ap; ap ! k = (Dec n e)\<rbrakk> \<Longrightarrow> start_of (layout_of ap) (Suc k) = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2557 |
start_of (layout_of ap) k + 2 * n + 16" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2558 |
apply(rule_tac start_of_Suc2, auto simp: abc_fetch.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2559 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2560 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2561 |
lemma inc_state_all_le: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2562 |
"\<lbrakk>k < length ap; ap ! k = Inc n; |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2563 |
(a, b) \<in> set (shift (shift tinc_b (2 * n)) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2564 |
(start_of (layout_of ap) k - Suc 0))\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2565 |
\<Longrightarrow> b \<le> start_of (layout_of ap) (length ap)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2566 |
apply(subgoal_tac "b \<le> start_of (layout_of ap) (Suc k)") |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2567 |
apply(subgoal_tac "start_of (layout_of ap) (Suc k) \<le> start_of (layout_of ap) (length ap) ") |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2568 |
apply(arith) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2569 |
apply(case_tac "Suc k = length ap", simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2570 |
apply(rule_tac start_of_less, simp) |
291
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
2571 |
apply(auto simp: tinc_b_def shift.simps start_of_suc_inc length_of.simps ) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2572 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2573 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2574 |
lemma findnth_le[elim]: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2575 |
"(a, b) \<in> set (shift (findnth n) (start_of (layout_of ap) k - Suc 0)) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2576 |
\<Longrightarrow> b \<le> Suc (start_of (layout_of ap) k + 2 * n)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2577 |
apply(induct n, simp add: findnth.simps shift.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2578 |
apply(simp add: findnth.simps shift_append, auto) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2579 |
apply(auto simp: shift.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2580 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2581 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2582 |
lemma findnth_state_all_le1: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2583 |
"\<lbrakk>k < length ap; ap ! k = Inc n; |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2584 |
(a, b) \<in> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2585 |
set (shift (findnth n) (start_of (layout_of ap) k - Suc 0))\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2586 |
\<Longrightarrow> b \<le> start_of (layout_of ap) (length ap)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2587 |
apply(subgoal_tac "b \<le> start_of (layout_of ap) (Suc k)") |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2588 |
apply(subgoal_tac "start_of (layout_of ap) (Suc k) \<le> start_of (layout_of ap) (length ap) ") |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2589 |
apply(arith) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2590 |
apply(case_tac "Suc k = length ap", simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2591 |
apply(rule_tac start_of_less, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2592 |
apply(subgoal_tac "b \<le> start_of (layout_of ap) k + 2*n + 1 \<and> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2593 |
start_of (layout_of ap) k + 2*n + 1 \<le> start_of (layout_of ap) (Suc k)", auto) |
291
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
2594 |
apply(auto simp: tinc_b_def shift.simps length_of.simps start_of_suc_inc) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2595 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2596 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2597 |
lemma start_of_eq: "length ap < as \<Longrightarrow> start_of (layout_of ap) as = start_of (layout_of ap) (length ap)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2598 |
apply(induct as, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2599 |
apply(case_tac "length ap < as", simp add: start_of.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2600 |
apply(subgoal_tac "as = length ap") |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2601 |
apply(simp add: start_of.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2602 |
apply arith |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2603 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2604 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2605 |
lemma start_of_all_le: "start_of (layout_of ap) as \<le> start_of (layout_of ap) (length ap)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2606 |
apply(subgoal_tac "as > length ap \<or> as = length ap \<or> as < length ap", |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2607 |
auto simp: start_of_eq start_of_less) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2608 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2609 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2610 |
lemma findnth_state_all_le2: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2611 |
"\<lbrakk>k < length ap; |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2612 |
ap ! k = Dec n e; |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2613 |
(a, b) \<in> set (shift (findnth n) (start_of (layout_of ap) k - Suc 0))\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2614 |
\<Longrightarrow> b \<le> start_of (layout_of ap) (length ap)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2615 |
apply(subgoal_tac "b \<le> start_of (layout_of ap) k + 2*n + 1 \<and> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2616 |
start_of (layout_of ap) k + 2*n + 1 \<le> start_of (layout_of ap) (Suc k) \<and> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2617 |
start_of (layout_of ap) (Suc k) \<le> start_of (layout_of ap) (length ap)", auto) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2618 |
apply(subgoal_tac "start_of (layout_of ap) (Suc k) = |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2619 |
start_of (layout_of ap) k + 2*n + 16", simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2620 |
apply(simp add: start_of_suc_dec) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2621 |
apply(rule_tac start_of_all_le) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2622 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2623 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2624 |
lemma dec_state_all_le[simp]: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2625 |
"\<lbrakk>k < length ap; ap ! k = Dec n e; |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2626 |
(a, b) \<in> set (shift (shift tdec_b (2 * n)) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2627 |
(start_of (layout_of ap) k - Suc 0))\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2628 |
\<Longrightarrow> b \<le> start_of (layout_of ap) (length ap)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
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") |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2630 |
prefer 2 |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2631 |
apply(subgoal_tac "start_of (layout_of ap) (Suc k) = start_of (layout_of ap) k + 2*n + 16 |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2632 |
\<and> start_of (layout_of ap) (Suc k) \<le> start_of (layout_of ap) (length ap)") |
291
93db7414931d
More naming of lemmas, cleanup of Abacus and NatBijection
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
290
diff
changeset
|
2633 |
apply(simp, rule_tac conjI) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2634 |
apply(simp add: start_of_suc_dec) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2635 |
apply(rule_tac start_of_all_le) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2636 |
apply(auto simp: tdec_b_def shift.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2637 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2638 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2639 |
lemma tms_any_less: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2640 |
"\<lbrakk>k < length ap; (a, b) \<in> set (tms_of ap ! k)\<rbrakk> \<Longrightarrow> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2641 |
b \<le> start_of (layout_of ap) (length ap)" |
190
f1ecb4a68a54
renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
2642 |
apply(case_tac "ap!k", auto simp: tms_of.simps tpairs_of.simps ci.simps shift_append adjust.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2643 |
apply(erule_tac findnth_state_all_le1, simp_all) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2644 |
apply(erule_tac inc_state_all_le, simp_all) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2645 |
apply(erule_tac findnth_state_all_le2, simp_all) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2646 |
apply(rule_tac start_of_all_le) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2647 |
apply(rule_tac start_of_all_le) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2648 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2649 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2650 |
lemma concat_in: "i < length (concat xs) \<Longrightarrow> |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2651 |
\<exists>k < length xs. concat xs ! i \<in> set (xs ! k)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2652 |
apply(induct xs rule: rev_induct, simp, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2653 |
apply(case_tac "i < length (concat xs)", simp) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2654 |
apply(erule_tac exE, rule_tac x = k in exI) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2655 |
apply(simp add: nth_append) |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2656 |
apply(rule_tac x = "length xs" in exI, simp) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2657 |
apply(simp add: nth_append) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2658 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2659 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2660 |
lemma length_tms_of[simp]: "length (tms_of ap) = length ap" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2661 |
apply(simp add: tms_of.simps tpairs_of.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2662 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2663 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2664 |
declare length_concat[simp] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2665 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2666 |
lemma in_tms: "i < length (tm_of ap) \<Longrightarrow> \<exists> k < length ap. (tm_of ap ! i) \<in> set (tms_of ap ! k)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2667 |
apply(simp only: tm_of.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2668 |
using concat_in[of i "tms_of ap"] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2669 |
apply(auto) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2670 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2671 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2672 |
lemma all_le_start_of: "list_all (\<lambda>(acn, s). |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2673 |
s \<le> start_of (layout_of ap) (length ap)) (tm_of ap)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2674 |
apply(simp only: list_all_length) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2675 |
apply(rule_tac allI, rule_tac impI) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2676 |
apply(drule_tac in_tms, auto elim: tms_any_less) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2677 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2678 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2679 |
lemma length_ci: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2680 |
"\<lbrakk>k < length ap; length (ci ly y (ap ! k)) = 2 * qa\<rbrakk> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2681 |
\<Longrightarrow> layout_of ap ! k = qa" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2682 |
apply(case_tac "ap ! k") |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2683 |
apply(auto simp: layout_of.simps ci.simps |
190
f1ecb4a68a54
renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
2684 |
length_of.simps tinc_b_def tdec_b_def length_findnth adjust.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2685 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2686 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2687 |
lemma ci_even[intro]: "length (ci ly y i) mod 2 = 0" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2688 |
apply(case_tac i, auto simp: ci.simps length_findnth |
190
f1ecb4a68a54
renamed sete definition to adjust and old special case of adjust to adjust0
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
172
diff
changeset
|
2689 |
tinc_b_def adjust.simps tdec_b_def) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2690 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2691 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2692 |
lemma sum_list_ci_even[intro]: "sum_list (map (length \<circ> (\<lambda>(x, y). ci ly x y)) zs) mod 2 = 0" |
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2693 |
apply(induct zs rule: rev_induct, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2694 |
apply(case_tac x, simp) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2695 |
apply(subgoal_tac "length (ci ly a b) mod 2 = 0") |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2696 |
apply(auto) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2697 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2698 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2699 |
lemma zip_pre: |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2700 |
"(length ys) \<le> length ap \<Longrightarrow> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2701 |
zip ys ap = zip ys (take (length ys) (ap::'a list))" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2702 |
proof(induct ys arbitrary: ap, simp, case_tac ap, simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2703 |
fix a ys ap aa list |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2704 |
assume ind: "\<And>(ap::'a list). length ys \<le> length ap \<Longrightarrow> |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2705 |
zip ys ap = zip ys (take (length ys) ap)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2706 |
and h: "length (a # ys) \<le> length ap" "(ap::'a list) = aa # (list::'a list)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2707 |
from h show "zip (a # ys) ap = zip (a # ys) (take (length (a # ys)) ap)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2708 |
using ind[of list] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2709 |
apply(simp) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2710 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2711 |
qed |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2712 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2713 |
lemma length_start_of_tm: "start_of (layout_of ap) (length ap) = Suc (length (tm_of ap) div 2)" |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2714 |
using tpa_states[of "tm_of ap" "length ap" ap] |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2715 |
apply(simp add: tm_of.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2716 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2717 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2718 |
lemma list_all_add_6E[elim]: "list_all (\<lambda>(acn, s). s \<le> Suc q) xs |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2719 |
\<Longrightarrow> list_all (\<lambda>(acn, s). s \<le> q + (2 * n + 6)) xs" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2720 |
by(auto simp: list_all_length) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2721 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2722 |
lemma mopup_b_12[simp]: "length mopup_b = 12" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2723 |
apply(simp add: mopup_b_def) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2724 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2725 |
|
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2726 |
lemma mp_up_all_le: "list_all (\<lambda>(acn, s). s \<le> q + (2 * n + 6)) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2727 |
[(R, Suc (Suc (2 * n + q))), (R, Suc (2 * n + q)), |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2728 |
(L, 5 + 2 * n + q), (W0, Suc (Suc (Suc (2 * n + q)))), (R, 4 + 2 * n + q), |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2729 |
(W0, Suc (Suc (Suc (2 * n + q)))), (R, Suc (Suc (2 * n + q))), |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2730 |
(W0, Suc (Suc (Suc (2 * n + q)))), (L, 5 + 2 * n + q), |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2731 |
(L, 6 + 2 * n + q), (R, 0), (L, 6 + 2 * n + q)]" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2732 |
by(auto) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2733 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2734 |
lemma mopup_le6[simp]: "(a, b) \<in> set (mopup_a n) \<Longrightarrow> b \<le> 2 * n + 6" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2735 |
apply(induct n, auto simp: mopup_a.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2736 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2737 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2738 |
lemma shift_le2[simp]: "(a, b) \<in> set (shift (mopup n) x) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2739 |
\<Longrightarrow> b \<le> (2 * x + length (mopup n)) div 2" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2740 |
apply(auto simp: mopup.simps shift_append shift.simps) |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2741 |
apply(auto simp: mopup_b_def) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2742 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2743 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2744 |
lemma mopup_ge2[intro]: " 2 \<le> x + length (mopup n)" |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2745 |
apply(simp add: mopup.simps) |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2746 |
done |
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2747 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2748 |
lemma mopup_even[intro]: " (2 * x + length (mopup n)) mod 2 = 0" |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2749 |
by(auto simp: mopup.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2750 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2751 |
lemma mopup_div_2[simp]: "b \<le> Suc x |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2752 |
\<Longrightarrow> b \<le> (2 * x + length (mopup n)) div 2" |
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2753 |
by(auto simp: mopup.simps) |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2754 |
|
288
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2755 |
lemma wf_tm_from_abacus: assumes "tp = tm_of ap" |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2756 |
shows "tm_wf0 (tp @ shift (mopup n) (length tp div 2))" |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2757 |
proof - |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2758 |
have "is_even (length (mopup n))" for n using tm_wf.simps by blast |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2759 |
moreover have "(aa, ba) \<in> set (mopup n) \<Longrightarrow> ba \<le> length (mopup n) div 2" for aa ba |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2760 |
by (metis (no_types, lifting) add_cancel_left_right case_prodD tm_wf.simps wf_mopup) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2761 |
moreover have "(\<forall>x\<in>set (tm_of ap). case x of (acn, s) \<Rightarrow> s \<le> Suc (sum_list (layout_of ap))) \<Longrightarrow> |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2762 |
(a, b) \<in> set (tm_of ap) \<Longrightarrow> b \<le> sum_list (layout_of ap) + length (mopup n) div 2" |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2763 |
for a b s |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2764 |
by (metis (no_types, lifting) add_Suc add_cancel_left_right case_prodD div_mult_mod_eq le_SucE mult_2_right not_numeral_le_zero tm_wf.simps trans_le_add1 wf_mopup) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2765 |
ultimately show ?thesis unfolding assms |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2766 |
using length_start_of_tm[of ap] all_le_start_of[of ap] tm_wf.simps |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2767 |
by(auto simp: List.list_all_iff shift.simps) |
a9003e6d0463
Up to date for Isabelle 2018. Gave names to simp rules in UF and UTM
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
285
diff
changeset
|
2768 |
qed |
70
2363eb91d9fd
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2769 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2770 |
lemma wf_tm_from_recf: |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2771 |
assumes compile: "tp = tm_of_rec recf" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2772 |
shows "tm_wf0 tp" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2773 |
proof - |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2774 |
obtain a b c where "rec_ci recf = (a, b, c)" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2775 |
by (metis prod_cases3) |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2776 |
thus "?thesis" |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2777 |
using compile |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2778 |
using wf_tm_from_abacus[of "tm_of (a [+] dummy_abc b)" "(a [+] dummy_abc b)" b] |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2779 |
by simp |
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2780 |
qed |
290
6e1c03614d36
Gave lemmas names in Abacus.ty
Sebastiaan Joosten <sebastiaan.joosten@uibk.ac.at>
parents:
288
diff
changeset
|
2781 |
|
229
d8e6f0798e23
much simplified version of Recursive.thy
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
204
diff
changeset
|
2782 |
end |