author | bulwahn |
Thu, 12 Nov 2009 20:38:57 +0100 | |
changeset 33649 | 854173fcd21c |
parent 32642 | 026e7c6a6d08 |
permissions | -rw-r--r-- |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
1 |
(* Title: HOL/MicroJava/BV/LBVSpec.thy |
8245 | 2 |
Author: Gerwin Klein |
3 |
Copyright 1999 Technische Universitaet Muenchen |
|
9054 | 4 |
*) |
8245 | 5 |
|
12911 | 6 |
header {* \isaheader{The Lightweight Bytecode Verifier} *} |
9054 | 7 |
|
27681 | 8 |
theory LBVSpec |
9 |
imports SemilatAlg Opt |
|
10 |
begin |
|
13062 | 11 |
|
8245 | 12 |
types |
13078 | 13 |
's certificate = "'s list" |
8245 | 14 |
|
12516 | 15 |
consts |
13078 | 16 |
merge :: "'s certificate \<Rightarrow> 's binop \<Rightarrow> 's ord \<Rightarrow> 's \<Rightarrow> nat \<Rightarrow> (nat \<times> 's) list \<Rightarrow> 's \<Rightarrow> 's" |
12516 | 17 |
primrec |
13078 | 18 |
"merge cert f r T pc [] x = x" |
19 |
"merge cert f r T pc (s#ss) x = merge cert f r T pc ss (let (pc',s') = s in |
|
20 |
if pc'=pc+1 then s' +_f x |
|
21 |
else if s' <=_r (cert!pc') then x |
|
22 |
else T)" |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
23 |
|
13062 | 24 |
constdefs |
13078 | 25 |
wtl_inst :: "'s certificate \<Rightarrow> 's binop \<Rightarrow> 's ord \<Rightarrow> 's \<Rightarrow> |
26 |
's step_type \<Rightarrow> nat \<Rightarrow> 's \<Rightarrow> 's" |
|
27 |
"wtl_inst cert f r T step pc s \<equiv> merge cert f r T pc (step pc s) (cert!(pc+1))" |
|
8245 | 28 |
|
13078 | 29 |
wtl_cert :: "'s certificate \<Rightarrow> 's binop \<Rightarrow> 's ord \<Rightarrow> 's \<Rightarrow> 's \<Rightarrow> |
30 |
's step_type \<Rightarrow> nat \<Rightarrow> 's \<Rightarrow> 's" |
|
31 |
"wtl_cert cert f r T B step pc s \<equiv> |
|
32 |
if cert!pc = B then |
|
33 |
wtl_inst cert f r T step pc s |
|
34 |
else |
|
35 |
if s <=_r (cert!pc) then wtl_inst cert f r T step pc (cert!pc) else T" |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
36 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
37 |
consts |
13078 | 38 |
wtl_inst_list :: "'a list \<Rightarrow> 's certificate \<Rightarrow> 's binop \<Rightarrow> 's ord \<Rightarrow> 's \<Rightarrow> 's \<Rightarrow> |
39 |
's step_type \<Rightarrow> nat \<Rightarrow> 's \<Rightarrow> 's" |
|
8245 | 40 |
primrec |
13101 | 41 |
"wtl_inst_list [] cert f r T B step pc s = s" |
42 |
"wtl_inst_list (i#is) cert f r T B step pc s = |
|
13078 | 43 |
(let s' = wtl_cert cert f r T B step pc s in |
13101 | 44 |
if s' = T \<or> s = T then T else wtl_inst_list is cert f r T B step (pc+1) s')" |
8245 | 45 |
|
46 |
constdefs |
|
13078 | 47 |
cert_ok :: "'s certificate \<Rightarrow> nat \<Rightarrow> 's \<Rightarrow> 's \<Rightarrow> 's set \<Rightarrow> bool" |
48 |
"cert_ok cert n T B A \<equiv> (\<forall>i < n. cert!i \<in> A \<and> cert!i \<noteq> T) \<and> (cert!n = B)" |
|
49 |
||
50 |
constdefs |
|
51 |
bottom :: "'a ord \<Rightarrow> 'a \<Rightarrow> bool" |
|
52 |
"bottom r B \<equiv> \<forall>x. B <=_r x" |
|
53 |
||
54 |
||
27681 | 55 |
locale lbv = Semilat + |
13078 | 56 |
fixes T :: "'a" ("\<top>") |
57 |
fixes B :: "'a" ("\<bottom>") |
|
58 |
fixes step :: "'a step_type" |
|
59 |
assumes top: "top r \<top>" |
|
60 |
assumes T_A: "\<top> \<in> A" |
|
61 |
assumes bot: "bottom r \<bottom>" |
|
62 |
assumes B_A: "\<bottom> \<in> A" |
|
63 |
||
64 |
fixes merge :: "'a certificate \<Rightarrow> nat \<Rightarrow> (nat \<times> 'a) list \<Rightarrow> 'a \<Rightarrow> 'a" |
|
65 |
defines mrg_def: "merge cert \<equiv> LBVSpec.merge cert f r \<top>" |
|
13062 | 66 |
|
13078 | 67 |
fixes wti :: "'a certificate \<Rightarrow> nat \<Rightarrow> 'a \<Rightarrow> 'a" |
68 |
defines wti_def: "wti cert \<equiv> wtl_inst cert f r \<top> step" |
|
69 |
||
70 |
fixes wtc :: "'a certificate \<Rightarrow> nat \<Rightarrow> 'a \<Rightarrow> 'a" |
|
71 |
defines wtc_def: "wtc cert \<equiv> wtl_cert cert f r \<top> \<bottom> step" |
|
72 |
||
73 |
fixes wtl :: "'b list \<Rightarrow> 'a certificate \<Rightarrow> nat \<Rightarrow> 'a \<Rightarrow> 'a" |
|
74 |
defines wtl_def: "wtl ins cert \<equiv> wtl_inst_list ins cert f r \<top> \<bottom> step" |
|
75 |
||
76 |
||
77 |
lemma (in lbv) wti: |
|
78 |
"wti c pc s \<equiv> merge c pc (step pc s) (c!(pc+1))" |
|
79 |
by (simp add: wti_def mrg_def wtl_inst_def) |
|
80 |
||
81 |
lemma (in lbv) wtc: |
|
82 |
"wtc c pc s \<equiv> if c!pc = \<bottom> then wti c pc s else if s <=_r c!pc then wti c pc (c!pc) else \<top>" |
|
83 |
by (unfold wtc_def wti_def wtl_cert_def) |
|
84 |
||
85 |
||
86 |
lemma cert_okD1 [intro?]: |
|
87 |
"cert_ok c n T B A \<Longrightarrow> pc < n \<Longrightarrow> c!pc \<in> A" |
|
13062 | 88 |
by (unfold cert_ok_def) fast |
89 |
||
13078 | 90 |
lemma cert_okD2 [intro?]: |
91 |
"cert_ok c n T B A \<Longrightarrow> c!n = B" |
|
13071 | 92 |
by (simp add: cert_ok_def) |
93 |
||
13078 | 94 |
lemma cert_okD3 [intro?]: |
95 |
"cert_ok c n T B A \<Longrightarrow> B \<in> A \<Longrightarrow> pc < n \<Longrightarrow> c!Suc pc \<in> A" |
|
13071 | 96 |
by (drule Suc_leI) (auto simp add: le_eq_less_or_eq dest: cert_okD1 cert_okD2) |
97 |
||
13078 | 98 |
lemma cert_okD4 [intro?]: |
99 |
"cert_ok c n T B A \<Longrightarrow> pc < n \<Longrightarrow> c!pc \<noteq> T" |
|
100 |
by (simp add: cert_ok_def) |
|
13062 | 101 |
|
102 |
declare Let_def [simp] |
|
103 |
||
104 |
section "more semilattice lemmas" |
|
105 |
||
13078 | 106 |
|
107 |
lemma (in lbv) sup_top [simp, elim]: |
|
108 |
assumes x: "x \<in> A" |
|
109 |
shows "x +_f \<top> = \<top>" |
|
13062 | 110 |
proof - |
13078 | 111 |
from top have "x +_f \<top> <=_r \<top>" .. |
23464 | 112 |
moreover from x T_A have "\<top> <=_r x +_f \<top>" .. |
13078 | 113 |
ultimately show ?thesis .. |
13062 | 114 |
qed |
115 |
||
13078 | 116 |
lemma (in lbv) plusplussup_top [simp, elim]: |
117 |
"set xs \<subseteq> A \<Longrightarrow> xs ++_f \<top> = \<top>" |
|
13062 | 118 |
by (induct xs) auto |
13078 | 119 |
|
120 |
||
13062 | 121 |
|
27681 | 122 |
lemma (in Semilat) pp_ub1': |
13078 | 123 |
assumes S: "snd`set S \<subseteq> A" |
124 |
assumes y: "y \<in> A" and ab: "(a, b) \<in> set S" |
|
23281 | 125 |
shows "b <=_r map snd [(p', t') \<leftarrow> S . p' = a] ++_f y" |
13078 | 126 |
proof - |
127 |
from S have "\<forall>(x,y) \<in> set S. y \<in> A" by auto |
|
128 |
with semilat y ab show ?thesis by - (rule ub1') |
|
129 |
qed |
|
13062 | 130 |
|
13078 | 131 |
lemma (in lbv) bottom_le [simp, intro]: |
132 |
"\<bottom> <=_r x" |
|
133 |
by (insert bot) (simp add: bottom_def) |
|
13062 | 134 |
|
13078 | 135 |
lemma (in lbv) le_bottom [simp]: |
136 |
"x <=_r \<bottom> = (x = \<bottom>)" |
|
137 |
by (blast intro: antisym_r) |
|
138 |
||
13062 | 139 |
|
140 |
||
141 |
section "merge" |
|
142 |
||
13078 | 143 |
lemma (in lbv) merge_Nil [simp]: |
144 |
"merge c pc [] x = x" by (simp add: mrg_def) |
|
145 |
||
146 |
lemma (in lbv) merge_Cons [simp]: |
|
147 |
"merge c pc (l#ls) x = merge c pc ls (if fst l=pc+1 then snd l +_f x |
|
148 |
else if snd l <=_r (c!fst l) then x |
|
149 |
else \<top>)" |
|
150 |
by (simp add: mrg_def split_beta) |
|
151 |
||
152 |
lemma (in lbv) merge_Err [simp]: |
|
153 |
"snd`set ss \<subseteq> A \<Longrightarrow> merge c pc ss \<top> = \<top>" |
|
13062 | 154 |
by (induct ss) auto |
8245 | 155 |
|
13078 | 156 |
lemma (in lbv) merge_not_top: |
157 |
"\<And>x. snd`set ss \<subseteq> A \<Longrightarrow> merge c pc ss x \<noteq> \<top> \<Longrightarrow> |
|
158 |
\<forall>(pc',s') \<in> set ss. (pc' \<noteq> pc+1 \<longrightarrow> s' <=_r (c!pc'))" |
|
159 |
(is "\<And>x. ?set ss \<Longrightarrow> ?merge ss x \<Longrightarrow> ?P ss") |
|
13062 | 160 |
proof (induct ss) |
161 |
show "?P []" by simp |
|
162 |
next |
|
13078 | 163 |
fix x ls l |
164 |
assume "?set (l#ls)" then obtain set: "snd`set ls \<subseteq> A" by simp |
|
165 |
assume merge: "?merge (l#ls) x" |
|
13062 | 166 |
moreover |
23464 | 167 |
obtain pc' s' where l: "l = (pc',s')" by (cases l) |
13062 | 168 |
ultimately |
23464 | 169 |
obtain x' where merge': "?merge ls x'" by simp |
170 |
assume "\<And>x. ?set ls \<Longrightarrow> ?merge ls x \<Longrightarrow> ?P ls" hence "?P ls" using set merge' . |
|
13062 | 171 |
moreover |
13078 | 172 |
from merge set |
23464 | 173 |
have "pc' \<noteq> pc+1 \<longrightarrow> s' <=_r (c!pc')" by (simp add: l split: split_if_asm) |
13062 | 174 |
ultimately |
23464 | 175 |
show "?P (l#ls)" by (simp add: l) |
13062 | 176 |
qed |
177 |
||
9012 | 178 |
|
13078 | 179 |
lemma (in lbv) merge_def: |
13062 | 180 |
shows |
13078 | 181 |
"\<And>x. x \<in> A \<Longrightarrow> snd`set ss \<subseteq> A \<Longrightarrow> |
182 |
merge c pc ss x = |
|
183 |
(if \<forall>(pc',s') \<in> set ss. pc'\<noteq>pc+1 \<longrightarrow> s' <=_r c!pc' then |
|
23281 | 184 |
map snd [(p',t') \<leftarrow> ss. p'=pc+1] ++_f x |
13078 | 185 |
else \<top>)" |
13062 | 186 |
(is "\<And>x. _ \<Longrightarrow> _ \<Longrightarrow> ?merge ss x = ?if ss x" is "\<And>x. _ \<Longrightarrow> _ \<Longrightarrow> ?P ss x") |
187 |
proof (induct ss) |
|
188 |
fix x show "?P [] x" by simp |
|
189 |
next |
|
13078 | 190 |
fix x assume x: "x \<in> A" |
191 |
fix l::"nat \<times> 'a" and ls |
|
192 |
assume "snd`set (l#ls) \<subseteq> A" |
|
193 |
then obtain l: "snd l \<in> A" and ls: "snd`set ls \<subseteq> A" by auto |
|
194 |
assume "\<And>x. x \<in> A \<Longrightarrow> snd`set ls \<subseteq> A \<Longrightarrow> ?P ls x" |
|
23464 | 195 |
hence IH: "\<And>x. x \<in> A \<Longrightarrow> ?P ls x" using ls by iprover |
13062 | 196 |
obtain pc' s' where [simp]: "l = (pc',s')" by (cases l) |
197 |
hence "?merge (l#ls) x = ?merge ls |
|
13078 | 198 |
(if pc'=pc+1 then s' +_f x else if s' <=_r c!pc' then x else \<top>)" |
13062 | 199 |
(is "?merge (l#ls) x = ?merge ls ?if'") |
200 |
by simp |
|
201 |
also have "\<dots> = ?if ls ?if'" |
|
202 |
proof - |
|
13078 | 203 |
from l have "s' \<in> A" by simp |
204 |
with x have "s' +_f x \<in> A" by simp |
|
23464 | 205 |
with x T_A have "?if' \<in> A" by auto |
13062 | 206 |
hence "?P ls ?if'" by (rule IH) thus ?thesis by simp |
207 |
qed |
|
208 |
also have "\<dots> = ?if (l#ls) x" |
|
13078 | 209 |
proof (cases "\<forall>(pc', s')\<in>set (l#ls). pc'\<noteq>pc+1 \<longrightarrow> s' <=_r c!pc'") |
13062 | 210 |
case True |
13078 | 211 |
hence "\<forall>(pc', s')\<in>set ls. pc'\<noteq>pc+1 \<longrightarrow> s' <=_r c!pc'" by auto |
13062 | 212 |
moreover |
213 |
from True have |
|
23281 | 214 |
"map snd [(p',t')\<leftarrow>ls . p'=pc+1] ++_f ?if' = |
215 |
(map snd [(p',t')\<leftarrow>l#ls . p'=pc+1] ++_f x)" |
|
13062 | 216 |
by simp |
217 |
ultimately |
|
218 |
show ?thesis using True by simp |
|
219 |
next |
|
13078 | 220 |
case False |
221 |
moreover |
|
23281 | 222 |
from ls have "set (map snd [(p', t')\<leftarrow>ls . p' = Suc pc]) \<subseteq> A" by auto |
13078 | 223 |
ultimately show ?thesis by auto |
13062 | 224 |
qed |
225 |
finally show "?P (l#ls) x" . |
|
226 |
qed |
|
227 |
||
13078 | 228 |
lemma (in lbv) merge_not_top_s: |
229 |
assumes x: "x \<in> A" and ss: "snd`set ss \<subseteq> A" |
|
230 |
assumes m: "merge c pc ss x \<noteq> \<top>" |
|
23281 | 231 |
shows "merge c pc ss x = (map snd [(p',t') \<leftarrow> ss. p'=pc+1] ++_f x)" |
13062 | 232 |
proof - |
13078 | 233 |
from ss m have "\<forall>(pc',s') \<in> set ss. (pc' \<noteq> pc+1 \<longrightarrow> s' <=_r c!pc')" |
234 |
by (rule merge_not_top) |
|
235 |
with x ss m show ?thesis by - (drule merge_def, auto split: split_if_asm) |
|
13062 | 236 |
qed |
237 |
||
238 |
section "wtl-inst-list" |
|
10042 | 239 |
|
10812
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10638
diff
changeset
|
240 |
lemmas [iff] = not_Err_eq |
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10638
diff
changeset
|
241 |
|
13078 | 242 |
lemma (in lbv) wtl_Nil [simp]: "wtl [] c pc s = s" |
243 |
by (simp add: wtl_def) |
|
244 |
||
245 |
lemma (in lbv) wtl_Cons [simp]: |
|
246 |
"wtl (i#is) c pc s = |
|
247 |
(let s' = wtc c pc s in if s' = \<top> \<or> s = \<top> then \<top> else wtl is c (pc+1) s')" |
|
248 |
by (simp add: wtl_def wtc_def) |
|
249 |
||
250 |
lemma (in lbv) wtl_Cons_not_top: |
|
251 |
"wtl (i#is) c pc s \<noteq> \<top> = |
|
252 |
(wtc c pc s \<noteq> \<top> \<and> s \<noteq> T \<and> wtl is c (pc+1) (wtc c pc s) \<noteq> \<top>)" |
|
10812
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10638
diff
changeset
|
253 |
by (auto simp del: split_paired_Ex) |
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
254 |
|
13078 | 255 |
lemma (in lbv) wtl_top [simp]: "wtl ls c pc \<top> = \<top>" |
256 |
by (cases ls) auto |
|
257 |
||
258 |
lemma (in lbv) wtl_not_top: |
|
259 |
"wtl ls c pc s \<noteq> \<top> \<Longrightarrow> s \<noteq> \<top>" |
|
260 |
by (cases "s=\<top>") auto |
|
9012 | 261 |
|
13078 | 262 |
lemma (in lbv) wtl_append [simp]: |
263 |
"\<And>pc s. wtl (a@b) c pc s = wtl b c (pc+length a) (wtl a c pc s)" |
|
264 |
by (induct a) auto |
|
265 |
||
266 |
lemma (in lbv) wtl_take: |
|
267 |
"wtl is c pc s \<noteq> \<top> \<Longrightarrow> wtl (take pc' is) c pc s \<noteq> \<top>" |
|
268 |
(is "?wtl is \<noteq> _ \<Longrightarrow> _") |
|
9183 | 269 |
proof - |
13078 | 270 |
assume "?wtl is \<noteq> \<top>" |
271 |
hence "?wtl (take pc' is @ drop pc' is) \<noteq> \<top>" by simp |
|
272 |
thus ?thesis by (auto dest!: wtl_not_top simp del: append_take_drop_id) |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
273 |
qed |
9012 | 274 |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
275 |
lemma take_Suc: |
13078 | 276 |
"\<forall>n. n < length l \<longrightarrow> take (Suc n) l = (take n l)@[l!n]" (is "?P l") |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
277 |
proof (induct l) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
278 |
show "?P []" by simp |
12516 | 279 |
next |
280 |
fix x xs assume IH: "?P xs" |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
281 |
show "?P (x#xs)" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
282 |
proof (intro strip) |
12516 | 283 |
fix n assume "n < length (x#xs)" |
284 |
with IH show "take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]" |
|
285 |
by (cases n, auto) |
|
9183 | 286 |
qed |
287 |
qed |
|
9012 | 288 |
|
13078 | 289 |
lemma (in lbv) wtl_Suc: |
290 |
assumes suc: "pc+1 < length is" |
|
291 |
assumes wtl: "wtl (take pc is) c 0 s \<noteq> \<top>" |
|
292 |
shows "wtl (take (pc+1) is) c 0 s = wtc c pc (wtl (take pc is) c 0 s)" |
|
9183 | 293 |
proof - |
13062 | 294 |
from suc have "take (pc+1) is=(take pc is)@[is!pc]" by (simp add: take_Suc) |
32642
026e7c6a6d08
be more cautious wrt. simp rules: inf_absorb1, inf_absorb2, sup_absorb1, sup_absorb2 are no simp rules by default any longer
haftmann
parents:
32443
diff
changeset
|
295 |
with suc wtl show ?thesis by (simp add: min_max.inf_absorb2) |
9183 | 296 |
qed |
9012 | 297 |
|
13078 | 298 |
lemma (in lbv) wtl_all: |
299 |
assumes all: "wtl is c 0 s \<noteq> \<top>" (is "?wtl is \<noteq> _") |
|
300 |
assumes pc: "pc < length is" |
|
301 |
shows "wtc c pc (wtl (take pc is) c 0 s) \<noteq> \<top>" |
|
9183 | 302 |
proof - |
13062 | 303 |
from pc have "0 < length (drop pc is)" by simp |
12516 | 304 |
then obtain i r where Cons: "drop pc is = i#r" |
15109 | 305 |
by (auto simp add: neq_Nil_conv simp del: length_drop drop_eq_Nil) |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
306 |
hence "i#r = drop pc is" .. |
13078 | 307 |
with all have take: "?wtl (take pc is@i#r) \<noteq> \<top>" by simp |
12516 | 308 |
from pc have "is!pc = drop pc is ! 0" by simp |
309 |
with Cons have "is!pc = i" by simp |
|
32642
026e7c6a6d08
be more cautious wrt. simp rules: inf_absorb1, inf_absorb2, sup_absorb1, sup_absorb2 are no simp rules by default any longer
haftmann
parents:
32443
diff
changeset
|
310 |
with take pc show ?thesis by (auto simp add: min_max.inf_absorb2) |
9183 | 311 |
qed |
9012 | 312 |
|
13062 | 313 |
section "preserves-type" |
314 |
||
13078 | 315 |
lemma (in lbv) merge_pres: |
316 |
assumes s0: "snd`set ss \<subseteq> A" and x: "x \<in> A" |
|
317 |
shows "merge c pc ss x \<in> A" |
|
13062 | 318 |
proof - |
23281 | 319 |
from s0 have "set (map snd [(p', t')\<leftarrow>ss . p'=pc+1]) \<subseteq> A" by auto |
320 |
with x have "(map snd [(p', t')\<leftarrow>ss . p'=pc+1] ++_f x) \<in> A" |
|
23464 | 321 |
by (auto intro!: plusplus_closed semilat) |
13078 | 322 |
with s0 x show ?thesis by (simp add: merge_def T_A) |
13062 | 323 |
qed |
324 |
||
325 |
||
13078 | 326 |
lemma pres_typeD2: |
327 |
"pres_type step n A \<Longrightarrow> s \<in> A \<Longrightarrow> p < n \<Longrightarrow> snd`set (step p s) \<subseteq> A" |
|
328 |
by auto (drule pres_typeD) |
|
13062 | 329 |
|
13078 | 330 |
|
331 |
lemma (in lbv) wti_pres [intro?]: |
|
332 |
assumes pres: "pres_type step n A" |
|
333 |
assumes cert: "c!(pc+1) \<in> A" |
|
334 |
assumes s_pc: "s \<in> A" "pc < n" |
|
335 |
shows "wti c pc s \<in> A" |
|
13062 | 336 |
proof - |
13078 | 337 |
from pres s_pc have "snd`set (step pc s) \<subseteq> A" by (rule pres_typeD2) |
338 |
with cert show ?thesis by (simp add: wti merge_pres) |
|
13062 | 339 |
qed |
340 |
||
341 |
||
13078 | 342 |
lemma (in lbv) wtc_pres: |
23464 | 343 |
assumes pres: "pres_type step n A" |
344 |
assumes cert: "c!pc \<in> A" and cert': "c!(pc+1) \<in> A" |
|
345 |
assumes s: "s \<in> A" and pc: "pc < n" |
|
13078 | 346 |
shows "wtc c pc s \<in> A" |
13062 | 347 |
proof - |
23464 | 348 |
have "wti c pc s \<in> A" using pres cert' s pc .. |
349 |
moreover have "wti c pc (c!pc) \<in> A" using pres cert' cert pc .. |
|
13078 | 350 |
ultimately show ?thesis using T_A by (simp add: wtc) |
13062 | 351 |
qed |
352 |
||
13078 | 353 |
|
354 |
lemma (in lbv) wtl_pres: |
|
355 |
assumes pres: "pres_type step (length is) A" |
|
356 |
assumes cert: "cert_ok c (length is) \<top> \<bottom> A" |
|
357 |
assumes s: "s \<in> A" |
|
358 |
assumes all: "wtl is c 0 s \<noteq> \<top>" |
|
359 |
shows "pc < length is \<Longrightarrow> wtl (take pc is) c 0 s \<in> A" |
|
360 |
(is "?len pc \<Longrightarrow> ?wtl pc \<in> A") |
|
13062 | 361 |
proof (induct pc) |
13078 | 362 |
from s show "?wtl 0 \<in> A" by simp |
13062 | 363 |
next |
23464 | 364 |
fix n assume IH: "Suc n < length is" |
365 |
then have n: "n < length is" by simp |
|
366 |
from IH have n1: "n+1 < length is" by simp |
|
367 |
assume prem: "n < length is \<Longrightarrow> ?wtl n \<in> A" |
|
368 |
have "wtc c n (?wtl n) \<in> A" |
|
369 |
using pres _ _ _ n |
|
370 |
proof (rule wtc_pres) |
|
371 |
from prem n show "?wtl n \<in> A" . |
|
372 |
from cert n show "c!n \<in> A" by (rule cert_okD1) |
|
373 |
from cert n1 show "c!(n+1) \<in> A" by (rule cert_okD1) |
|
374 |
qed |
|
13078 | 375 |
also |
376 |
from all n have "?wtl n \<noteq> \<top>" by - (rule wtl_take) |
|
377 |
with n1 have "wtc c n (?wtl n) = ?wtl (n+1)" by (rule wtl_Suc [symmetric]) |
|
378 |
finally show "?wtl (Suc n) \<in> A" by simp |
|
13062 | 379 |
qed |
380 |
||
9183 | 381 |
end |