author | haftmann |
Tue, 22 Sep 2009 15:36:55 +0200 | |
changeset 32642 | 026e7c6a6d08 |
parent 32443 | 16464c3f86bd |
child 33954 | 1bc3b688548c |
permissions | -rw-r--r-- |
12516 | 1 |
(* Title: HOL/MicroJava/BV/Effect.thy |
2 |
Author: Gerwin Klein |
|
3 |
Copyright 2000 Technische Universitaet Muenchen |
|
4 |
*) |
|
5 |
||
12911 | 6 |
header {* \isaheader{Effect of Instructions on the State Type} *} |
12516 | 7 |
|
15481 | 8 |
theory Effect |
9 |
imports JVMType "../JVM/JVMExceptions" |
|
10 |
begin |
|
11 |
||
12516 | 12 |
|
13 |
types |
|
14 |
succ_type = "(p_count \<times> state_type option) list" |
|
15 |
||
16 |
text {* Program counter of successor instructions: *} |
|
17 |
consts |
|
13006 | 18 |
succs :: "instr \<Rightarrow> p_count \<Rightarrow> p_count list" |
12516 | 19 |
primrec |
20 |
"succs (Load idx) pc = [pc+1]" |
|
21 |
"succs (Store idx) pc = [pc+1]" |
|
22 |
"succs (LitPush v) pc = [pc+1]" |
|
23 |
"succs (Getfield F C) pc = [pc+1]" |
|
24 |
"succs (Putfield F C) pc = [pc+1]" |
|
25 |
"succs (New C) pc = [pc+1]" |
|
26 |
"succs (Checkcast C) pc = [pc+1]" |
|
27 |
"succs Pop pc = [pc+1]" |
|
28 |
"succs Dup pc = [pc+1]" |
|
29 |
"succs Dup_x1 pc = [pc+1]" |
|
30 |
"succs Dup_x2 pc = [pc+1]" |
|
31 |
"succs Swap pc = [pc+1]" |
|
32 |
"succs IAdd pc = [pc+1]" |
|
33 |
"succs (Ifcmpeq b) pc = [pc+1, nat (int pc + b)]" |
|
34 |
"succs (Goto b) pc = [nat (int pc + b)]" |
|
35 |
"succs Return pc = [pc]" |
|
36 |
"succs (Invoke C mn fpTs) pc = [pc+1]" |
|
37 |
"succs Throw pc = [pc]" |
|
38 |
||
39 |
text "Effect of instruction on the state type:" |
|
40 |
consts |
|
13006 | 41 |
eff' :: "instr \<times> jvm_prog \<times> state_type \<Rightarrow> state_type" |
12516 | 42 |
|
43 |
recdef eff' "{}" |
|
44 |
"eff' (Load idx, G, (ST, LT)) = (ok_val (LT ! idx) # ST, LT)" |
|
45 |
"eff' (Store idx, G, (ts#ST, LT)) = (ST, LT[idx:= OK ts])" |
|
46 |
"eff' (LitPush v, G, (ST, LT)) = (the (typeof (\<lambda>v. None) v) # ST, LT)" |
|
47 |
"eff' (Getfield F C, G, (oT#ST, LT)) = (snd (the (field (G,C) F)) # ST, LT)" |
|
48 |
"eff' (Putfield F C, G, (vT#oT#ST, LT)) = (ST,LT)" |
|
49 |
"eff' (New C, G, (ST,LT)) = (Class C # ST, LT)" |
|
50 |
"eff' (Checkcast C, G, (RefT rt#ST,LT)) = (Class C # ST,LT)" |
|
51 |
"eff' (Pop, G, (ts#ST,LT)) = (ST,LT)" |
|
52 |
"eff' (Dup, G, (ts#ST,LT)) = (ts#ts#ST,LT)" |
|
53 |
"eff' (Dup_x1, G, (ts1#ts2#ST,LT)) = (ts1#ts2#ts1#ST,LT)" |
|
54 |
"eff' (Dup_x2, G, (ts1#ts2#ts3#ST,LT)) = (ts1#ts2#ts3#ts1#ST,LT)" |
|
55 |
"eff' (Swap, G, (ts1#ts2#ST,LT)) = (ts2#ts1#ST,LT)" |
|
56 |
"eff' (IAdd, G, (PrimT Integer#PrimT Integer#ST,LT)) |
|
57 |
= (PrimT Integer#ST,LT)" |
|
58 |
"eff' (Ifcmpeq b, G, (ts1#ts2#ST,LT)) = (ST,LT)" |
|
59 |
"eff' (Goto b, G, s) = s" |
|
60 |
-- "Return has no successor instruction in the same method" |
|
61 |
"eff' (Return, G, s) = s" |
|
62 |
-- "Throw always terminates abruptly" |
|
63 |
"eff' (Throw, G, s) = s" |
|
64 |
"eff' (Invoke C mn fpTs, G, (ST,LT)) = (let ST' = drop (length fpTs) ST |
|
65 |
in (fst (snd (the (method (G,C) (mn,fpTs))))#(tl ST'),LT))" |
|
66 |
||
67 |
||
68 |
consts |
|
69 |
match_any :: "jvm_prog \<Rightarrow> p_count \<Rightarrow> exception_table \<Rightarrow> cname list" |
|
70 |
primrec |
|
71 |
"match_any G pc [] = []" |
|
72 |
"match_any G pc (e#es) = (let (start_pc, end_pc, handler_pc, catch_type) = e; |
|
73 |
es' = match_any G pc es |
|
74 |
in |
|
75 |
if start_pc <= pc \<and> pc < end_pc then catch_type#es' else es')" |
|
76 |
||
12951 | 77 |
consts |
13717 | 78 |
match :: "jvm_prog \<Rightarrow> xcpt \<Rightarrow> p_count \<Rightarrow> exception_table \<Rightarrow> cname list" |
12951 | 79 |
primrec |
80 |
"match G X pc [] = []" |
|
81 |
"match G X pc (e#es) = |
|
13717 | 82 |
(if match_exception_entry G (Xcpt X) pc e then [Xcpt X] else match G X pc es)" |
12951 | 83 |
|
84 |
lemma match_some_entry: |
|
13717 | 85 |
"match G X pc et = (if \<exists>e \<in> set et. match_exception_entry G (Xcpt X) pc e then [Xcpt X] else [])" |
12951 | 86 |
by (induct et) auto |
12516 | 87 |
|
88 |
consts |
|
13006 | 89 |
xcpt_names :: "instr \<times> jvm_prog \<times> p_count \<times> exception_table \<Rightarrow> cname list" |
12516 | 90 |
recdef xcpt_names "{}" |
13717 | 91 |
"xcpt_names (Getfield F C, G, pc, et) = match G NullPointer pc et" |
92 |
"xcpt_names (Putfield F C, G, pc, et) = match G NullPointer pc et" |
|
93 |
"xcpt_names (New C, G, pc, et) = match G OutOfMemory pc et" |
|
94 |
"xcpt_names (Checkcast C, G, pc, et) = match G ClassCast pc et" |
|
12516 | 95 |
"xcpt_names (Throw, G, pc, et) = match_any G pc et" |
96 |
"xcpt_names (Invoke C m p, G, pc, et) = match_any G pc et" |
|
97 |
"xcpt_names (i, G, pc, et) = []" |
|
98 |
||
99 |
||
100 |
constdefs |
|
101 |
xcpt_eff :: "instr \<Rightarrow> jvm_prog \<Rightarrow> p_count \<Rightarrow> state_type option \<Rightarrow> exception_table \<Rightarrow> succ_type" |
|
102 |
"xcpt_eff i G pc s et == |
|
103 |
map (\<lambda>C. (the (match_exception_table G C pc et), case s of None \<Rightarrow> None | Some s' \<Rightarrow> Some ([Class C], snd s'))) |
|
104 |
(xcpt_names (i,G,pc,et))" |
|
105 |
||
106 |
norm_eff :: "instr \<Rightarrow> jvm_prog \<Rightarrow> state_type option \<Rightarrow> state_type option" |
|
30235
58d147683393
Made Option a separate theory and renamed option_map to Option.map
nipkow
parents:
25362
diff
changeset
|
107 |
"norm_eff i G == Option.map (\<lambda>s. eff' (i,G,s))" |
12516 | 108 |
|
13006 | 109 |
eff :: "instr \<Rightarrow> jvm_prog \<Rightarrow> p_count \<Rightarrow> exception_table \<Rightarrow> state_type option \<Rightarrow> succ_type" |
12516 | 110 |
"eff i G pc et s == (map (\<lambda>pc'. (pc',norm_eff i G s)) (succs i pc)) @ (xcpt_eff i G pc s et)" |
111 |
||
12772 | 112 |
constdefs |
113 |
isPrimT :: "ty \<Rightarrow> bool" |
|
114 |
"isPrimT T == case T of PrimT T' \<Rightarrow> True | RefT T' \<Rightarrow> False" |
|
115 |
||
116 |
isRefT :: "ty \<Rightarrow> bool" |
|
117 |
"isRefT T == case T of PrimT T' \<Rightarrow> False | RefT T' \<Rightarrow> True" |
|
118 |
||
119 |
lemma isPrimT [simp]: |
|
120 |
"isPrimT T = (\<exists>T'. T = PrimT T')" by (simp add: isPrimT_def split: ty.splits) |
|
121 |
||
122 |
lemma isRefT [simp]: |
|
123 |
"isRefT T = (\<exists>T'. T = RefT T')" by (simp add: isRefT_def split: ty.splits) |
|
124 |
||
125 |
||
126 |
lemma "list_all2 P a b \<Longrightarrow> \<forall>(x,y) \<in> set (zip a b). P x y" |
|
127 |
by (simp add: list_all2_def) |
|
128 |
||
12516 | 129 |
|
130 |
text "Conditions under which eff is applicable:" |
|
131 |
consts |
|
13006 | 132 |
app' :: "instr \<times> jvm_prog \<times> p_count \<times> nat \<times> ty \<times> state_type \<Rightarrow> bool" |
12516 | 133 |
|
134 |
recdef app' "{}" |
|
12974 | 135 |
"app' (Load idx, G, pc, maxs, rT, s) = |
136 |
(idx < length (snd s) \<and> (snd s) ! idx \<noteq> Err \<and> length (fst s) < maxs)" |
|
137 |
"app' (Store idx, G, pc, maxs, rT, (ts#ST, LT)) = |
|
138 |
(idx < length LT)" |
|
139 |
"app' (LitPush v, G, pc, maxs, rT, s) = |
|
140 |
(length (fst s) < maxs \<and> typeof (\<lambda>t. None) v \<noteq> None)" |
|
141 |
"app' (Getfield F C, G, pc, maxs, rT, (oT#ST, LT)) = |
|
142 |
(is_class G C \<and> field (G,C) F \<noteq> None \<and> fst (the (field (G,C) F)) = C \<and> |
|
143 |
G \<turnstile> oT \<preceq> (Class C))" |
|
144 |
"app' (Putfield F C, G, pc, maxs, rT, (vT#oT#ST, LT)) = |
|
145 |
(is_class G C \<and> field (G,C) F \<noteq> None \<and> fst (the (field (G,C) F)) = C \<and> |
|
146 |
G \<turnstile> oT \<preceq> (Class C) \<and> G \<turnstile> vT \<preceq> (snd (the (field (G,C) F))))" |
|
147 |
"app' (New C, G, pc, maxs, rT, s) = |
|
148 |
(is_class G C \<and> length (fst s) < maxs)" |
|
149 |
"app' (Checkcast C, G, pc, maxs, rT, (RefT rt#ST,LT)) = |
|
150 |
(is_class G C)" |
|
151 |
"app' (Pop, G, pc, maxs, rT, (ts#ST,LT)) = |
|
152 |
True" |
|
153 |
"app' (Dup, G, pc, maxs, rT, (ts#ST,LT)) = |
|
154 |
(1+length ST < maxs)" |
|
155 |
"app' (Dup_x1, G, pc, maxs, rT, (ts1#ts2#ST,LT)) = |
|
156 |
(2+length ST < maxs)" |
|
157 |
"app' (Dup_x2, G, pc, maxs, rT, (ts1#ts2#ts3#ST,LT)) = |
|
158 |
(3+length ST < maxs)" |
|
159 |
"app' (Swap, G, pc, maxs, rT, (ts1#ts2#ST,LT)) = |
|
160 |
True" |
|
161 |
"app' (IAdd, G, pc, maxs, rT, (PrimT Integer#PrimT Integer#ST,LT)) = |
|
162 |
True" |
|
163 |
"app' (Ifcmpeq b, G, pc, maxs, rT, (ts#ts'#ST,LT)) = |
|
164 |
(0 \<le> int pc + b \<and> (isPrimT ts \<and> ts' = ts \<or> isRefT ts \<and> isRefT ts'))" |
|
165 |
"app' (Goto b, G, pc, maxs, rT, s) = |
|
166 |
(0 \<le> int pc + b)" |
|
167 |
"app' (Return, G, pc, maxs, rT, (T#ST,LT)) = |
|
168 |
(G \<turnstile> T \<preceq> rT)" |
|
169 |
"app' (Throw, G, pc, maxs, rT, (T#ST,LT)) = |
|
170 |
isRefT T" |
|
171 |
"app' (Invoke C mn fpTs, G, pc, maxs, rT, s) = |
|
172 |
(length fpTs < length (fst s) \<and> |
|
173 |
(let apTs = rev (take (length fpTs) (fst s)); |
|
174 |
X = hd (drop (length fpTs) (fst s)) |
|
175 |
in |
|
176 |
G \<turnstile> X \<preceq> Class C \<and> is_class G C \<and> method (G,C) (mn,fpTs) \<noteq> None \<and> |
|
177 |
list_all2 (\<lambda>x y. G \<turnstile> x \<preceq> y) apTs fpTs))" |
|
12772 | 178 |
|
12974 | 179 |
"app' (i,G, pc,maxs,rT,s) = False" |
12516 | 180 |
|
181 |
constdefs |
|
182 |
xcpt_app :: "instr \<Rightarrow> jvm_prog \<Rightarrow> nat \<Rightarrow> exception_table \<Rightarrow> bool" |
|
183 |
"xcpt_app i G pc et \<equiv> \<forall>C\<in>set(xcpt_names (i,G,pc,et)). is_class G C" |
|
184 |
||
13006 | 185 |
app :: "instr \<Rightarrow> jvm_prog \<Rightarrow> nat \<Rightarrow> ty \<Rightarrow> nat \<Rightarrow> exception_table \<Rightarrow> state_type option \<Rightarrow> bool" |
186 |
"app i G maxs rT pc et s == case s of None \<Rightarrow> True | Some t \<Rightarrow> app' (i,G,pc,maxs,rT,t) \<and> xcpt_app i G pc et" |
|
12516 | 187 |
|
188 |
||
13066 | 189 |
lemma match_any_match_table: |
190 |
"C \<in> set (match_any G pc et) \<Longrightarrow> match_exception_table G C pc et \<noteq> None" |
|
191 |
apply (induct et) |
|
192 |
apply simp |
|
193 |
apply simp |
|
194 |
apply clarify |
|
195 |
apply (simp split: split_if_asm) |
|
196 |
apply (auto simp add: match_exception_entry_def) |
|
197 |
done |
|
198 |
||
199 |
lemma match_X_match_table: |
|
200 |
"C \<in> set (match G X pc et) \<Longrightarrow> match_exception_table G C pc et \<noteq> None" |
|
201 |
apply (induct et) |
|
202 |
apply simp |
|
203 |
apply (simp split: split_if_asm) |
|
204 |
done |
|
205 |
||
206 |
lemma xcpt_names_in_et: |
|
207 |
"C \<in> set (xcpt_names (i,G,pc,et)) \<Longrightarrow> |
|
208 |
\<exists>e \<in> set et. the (match_exception_table G C pc et) = fst (snd (snd e))" |
|
209 |
apply (cases i) |
|
18576 | 210 |
apply (auto dest!: match_any_match_table match_X_match_table |
13066 | 211 |
dest: match_exception_table_in_et) |
212 |
done |
|
213 |
||
214 |
||
13006 | 215 |
lemma 1: "2 < length a \<Longrightarrow> (\<exists>l l' l'' ls. a = l#l'#l''#ls)" |
12516 | 216 |
proof (cases a) |
217 |
fix x xs assume "a = x#xs" "2 < length a" |
|
218 |
thus ?thesis by - (cases xs, simp, cases "tl xs", auto) |
|
219 |
qed auto |
|
220 |
||
13006 | 221 |
lemma 2: "\<not>(2 < length a) \<Longrightarrow> a = [] \<or> (\<exists> l. a = [l]) \<or> (\<exists> l l'. a = [l,l'])" |
12516 | 222 |
proof -; |
223 |
assume "\<not>(2 < length a)" |
|
224 |
hence "length a < (Suc (Suc (Suc 0)))" by simp |
|
225 |
hence * : "length a = 0 \<or> length a = Suc 0 \<or> length a = Suc (Suc 0)" |
|
226 |
by (auto simp add: less_Suc_eq) |
|
227 |
||
228 |
{ |
|
229 |
fix x |
|
230 |
assume "length x = Suc 0" |
|
231 |
hence "\<exists> l. x = [l]" by - (cases x, auto) |
|
232 |
} note 0 = this |
|
233 |
||
13006 | 234 |
have "length a = Suc (Suc 0) \<Longrightarrow> \<exists>l l'. a = [l,l']" by (cases a, auto dest: 0) |
12516 | 235 |
with * show ?thesis by (auto dest: 0) |
236 |
qed |
|
237 |
||
238 |
lemmas [simp] = app_def xcpt_app_def |
|
239 |
||
240 |
text {* |
|
241 |
\medskip |
|
242 |
simp rules for @{term app} |
|
243 |
*} |
|
244 |
lemma appNone[simp]: "app i G maxs rT pc et None = True" by simp |
|
245 |
||
246 |
||
247 |
lemma appLoad[simp]: |
|
248 |
"(app (Load idx) G maxs rT pc et (Some s)) = (\<exists>ST LT. s = (ST,LT) \<and> idx < length LT \<and> LT!idx \<noteq> Err \<and> length ST < maxs)" |
|
249 |
by (cases s, simp) |
|
250 |
||
251 |
lemma appStore[simp]: |
|
252 |
"(app (Store idx) G maxs rT pc et (Some s)) = (\<exists>ts ST LT. s = (ts#ST,LT) \<and> idx < length LT)" |
|
253 |
by (cases s, cases "2 < length (fst s)", auto dest: 1 2) |
|
254 |
||
255 |
lemma appLitPush[simp]: |
|
256 |
"(app (LitPush v) G maxs rT pc et (Some s)) = (\<exists>ST LT. s = (ST,LT) \<and> length ST < maxs \<and> typeof (\<lambda>v. None) v \<noteq> None)" |
|
257 |
by (cases s, simp) |
|
258 |
||
259 |
lemma appGetField[simp]: |
|
260 |
"(app (Getfield F C) G maxs rT pc et (Some s)) = |
|
261 |
(\<exists> oT vT ST LT. s = (oT#ST, LT) \<and> is_class G C \<and> |
|
13717 | 262 |
field (G,C) F = Some (C,vT) \<and> G \<turnstile> oT \<preceq> (Class C) \<and> (\<forall>x \<in> set (match G NullPointer pc et). is_class G x))" |
12516 | 263 |
by (cases s, cases "2 <length (fst s)", auto dest!: 1 2) |
264 |
||
265 |
lemma appPutField[simp]: |
|
266 |
"(app (Putfield F C) G maxs rT pc et (Some s)) = |
|
267 |
(\<exists> vT vT' oT ST LT. s = (vT#oT#ST, LT) \<and> is_class G C \<and> |
|
12951 | 268 |
field (G,C) F = Some (C, vT') \<and> G \<turnstile> oT \<preceq> (Class C) \<and> G \<turnstile> vT \<preceq> vT' \<and> |
13717 | 269 |
(\<forall>x \<in> set (match G NullPointer pc et). is_class G x))" |
12516 | 270 |
by (cases s, cases "2 <length (fst s)", auto dest!: 1 2) |
271 |
||
272 |
lemma appNew[simp]: |
|
273 |
"(app (New C) G maxs rT pc et (Some s)) = |
|
12951 | 274 |
(\<exists>ST LT. s=(ST,LT) \<and> is_class G C \<and> length ST < maxs \<and> |
13717 | 275 |
(\<forall>x \<in> set (match G OutOfMemory pc et). is_class G x))" |
12516 | 276 |
by (cases s, simp) |
277 |
||
278 |
lemma appCheckcast[simp]: |
|
279 |
"(app (Checkcast C) G maxs rT pc et (Some s)) = |
|
12951 | 280 |
(\<exists>rT ST LT. s = (RefT rT#ST,LT) \<and> is_class G C \<and> |
13717 | 281 |
(\<forall>x \<in> set (match G ClassCast pc et). is_class G x))" |
12516 | 282 |
by (cases s, cases "fst s", simp add: app_def) (cases "hd (fst s)", auto) |
283 |
||
284 |
lemma appPop[simp]: |
|
285 |
"(app Pop G maxs rT pc et (Some s)) = (\<exists>ts ST LT. s = (ts#ST,LT))" |
|
286 |
by (cases s, cases "2 <length (fst s)", auto dest: 1 2) |
|
287 |
||
288 |
||
289 |
lemma appDup[simp]: |
|
290 |
"(app Dup G maxs rT pc et (Some s)) = (\<exists>ts ST LT. s = (ts#ST,LT) \<and> 1+length ST < maxs)" |
|
291 |
by (cases s, cases "2 <length (fst s)", auto dest: 1 2) |
|
292 |
||
293 |
||
294 |
lemma appDup_x1[simp]: |
|
295 |
"(app Dup_x1 G maxs rT pc et (Some s)) = (\<exists>ts1 ts2 ST LT. s = (ts1#ts2#ST,LT) \<and> 2+length ST < maxs)" |
|
296 |
by (cases s, cases "2 <length (fst s)", auto dest: 1 2) |
|
297 |
||
298 |
||
299 |
lemma appDup_x2[simp]: |
|
300 |
"(app Dup_x2 G maxs rT pc et (Some s)) = (\<exists>ts1 ts2 ts3 ST LT. s = (ts1#ts2#ts3#ST,LT) \<and> 3+length ST < maxs)" |
|
301 |
by (cases s, cases "2 <length (fst s)", auto dest: 1 2) |
|
302 |
||
303 |
||
304 |
lemma appSwap[simp]: |
|
305 |
"app Swap G maxs rT pc et (Some s) = (\<exists>ts1 ts2 ST LT. s = (ts1#ts2#ST,LT))" |
|
25362 | 306 |
by (cases s, cases "2 <length (fst s)") (auto dest: 1 2) |
12516 | 307 |
|
308 |
||
309 |
lemma appIAdd[simp]: |
|
310 |
"app IAdd G maxs rT pc et (Some s) = (\<exists> ST LT. s = (PrimT Integer#PrimT Integer#ST,LT))" |
|
311 |
(is "?app s = ?P s") |
|
25362 | 312 |
proof (cases s) |
313 |
case (Pair a b) |
|
12516 | 314 |
have "?app (a,b) = ?P (a,b)" |
25362 | 315 |
proof (cases a) |
12516 | 316 |
fix t ts assume a: "a = t#ts" |
317 |
show ?thesis |
|
318 |
proof (cases t) |
|
319 |
fix p assume p: "t = PrimT p" |
|
320 |
show ?thesis |
|
321 |
proof (cases p) |
|
322 |
assume ip: "p = Integer" |
|
323 |
show ?thesis |
|
324 |
proof (cases ts) |
|
325 |
fix t' ts' assume t': "ts = t' # ts'" |
|
326 |
show ?thesis |
|
327 |
proof (cases t') |
|
328 |
fix p' assume "t' = PrimT p'" |
|
329 |
with t' ip p a |
|
25362 | 330 |
show ?thesis by (cases p') auto |
12516 | 331 |
qed (auto simp add: a p ip t') |
332 |
qed (auto simp add: a p ip) |
|
333 |
qed (auto simp add: a p) |
|
334 |
qed (auto simp add: a) |
|
335 |
qed auto |
|
336 |
with Pair show ?thesis by simp |
|
337 |
qed |
|
338 |
||
339 |
||
340 |
lemma appIfcmpeq[simp]: |
|
12974 | 341 |
"app (Ifcmpeq b) G maxs rT pc et (Some s) = |
342 |
(\<exists>ts1 ts2 ST LT. s = (ts1#ts2#ST,LT) \<and> 0 \<le> int pc + b \<and> |
|
343 |
((\<exists> p. ts1 = PrimT p \<and> ts2 = PrimT p) \<or> (\<exists>r r'. ts1 = RefT r \<and> ts2 = RefT r')))" |
|
12772 | 344 |
by (cases s, cases "2 <length (fst s)", auto dest!: 1 2) |
12516 | 345 |
|
346 |
lemma appReturn[simp]: |
|
347 |
"app Return G maxs rT pc et (Some s) = (\<exists>T ST LT. s = (T#ST,LT) \<and> (G \<turnstile> T \<preceq> rT))" |
|
348 |
by (cases s, cases "2 <length (fst s)", auto dest: 1 2) |
|
349 |
||
350 |
lemma appGoto[simp]: |
|
12974 | 351 |
"app (Goto b) G maxs rT pc et (Some s) = (0 \<le> int pc + b)" |
12516 | 352 |
by simp |
353 |
||
354 |
lemma appThrow[simp]: |
|
355 |
"app Throw G maxs rT pc et (Some s) = |
|
356 |
(\<exists>T ST LT r. s=(T#ST,LT) \<and> T = RefT r \<and> (\<forall>C \<in> set (match_any G pc et). is_class G C))" |
|
357 |
by (cases s, cases "2 < length (fst s)", auto dest: 1 2) |
|
358 |
||
359 |
lemma appInvoke[simp]: |
|
360 |
"app (Invoke C mn fpTs) G maxs rT pc et (Some s) = (\<exists>apTs X ST LT mD' rT' b'. |
|
361 |
s = ((rev apTs) @ (X # ST), LT) \<and> length apTs = length fpTs \<and> is_class G C \<and> |
|
362 |
G \<turnstile> X \<preceq> Class C \<and> (\<forall>(aT,fT)\<in>set(zip apTs fpTs). G \<turnstile> aT \<preceq> fT) \<and> |
|
363 |
method (G,C) (mn,fpTs) = Some (mD', rT', b') \<and> |
|
364 |
(\<forall>C \<in> set (match_any G pc et). is_class G C))" (is "?app s = ?P s") |
|
25362 | 365 |
proof (cases s) |
12772 | 366 |
note list_all2_def [simp] |
25362 | 367 |
case (Pair a b) |
13006 | 368 |
have "?app (a,b) \<Longrightarrow> ?P (a,b)" |
12516 | 369 |
proof - |
370 |
assume app: "?app (a,b)" |
|
371 |
hence "a = (rev (rev (take (length fpTs) a))) @ (drop (length fpTs) a) \<and> |
|
372 |
length fpTs < length a" (is "?a \<and> ?l") |
|
373 |
by (auto simp add: app_def) |
|
374 |
hence "?a \<and> 0 < length (drop (length fpTs) a)" (is "?a \<and> ?l") |
|
375 |
by auto |
|
376 |
hence "?a \<and> ?l \<and> length (rev (take (length fpTs) a)) = length fpTs" |
|
32443 | 377 |
by (auto) |
12516 | 378 |
hence "\<exists>apTs ST. a = rev apTs @ ST \<and> length apTs = length fpTs \<and> 0 < length ST" |
379 |
by blast |
|
380 |
hence "\<exists>apTs ST. a = rev apTs @ ST \<and> length apTs = length fpTs \<and> ST \<noteq> []" |
|
381 |
by blast |
|
382 |
hence "\<exists>apTs ST. a = rev apTs @ ST \<and> length apTs = length fpTs \<and> |
|
383 |
(\<exists>X ST'. ST = X#ST')" |
|
384 |
by (simp add: neq_Nil_conv) |
|
385 |
hence "\<exists>apTs X ST. a = rev apTs @ X # ST \<and> length apTs = length fpTs" |
|
386 |
by blast |
|
387 |
with app |
|
388 |
show ?thesis by (unfold app_def, clarsimp) blast |
|
389 |
qed |
|
390 |
with Pair |
|
12772 | 391 |
have "?app s \<Longrightarrow> ?P s" by (simp only:) |
12516 | 392 |
moreover |
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
|
393 |
have "?P s \<Longrightarrow> ?app s" by (clarsimp simp add: min_max.inf_absorb2) |
12516 | 394 |
ultimately |
12772 | 395 |
show ?thesis by (rule iffI) |
12516 | 396 |
qed |
397 |
||
398 |
lemma effNone: |
|
399 |
"(pc', s') \<in> set (eff i G pc et None) \<Longrightarrow> s' = None" |
|
400 |
by (auto simp add: eff_def xcpt_eff_def norm_eff_def) |
|
401 |
||
12772 | 402 |
|
403 |
lemma xcpt_app_lemma [code]: |
|
404 |
"xcpt_app i G pc et = list_all (is_class G) (xcpt_names (i, G, pc, et))" |
|
17088 | 405 |
by (simp add: list_all_iff) |
12772 | 406 |
|
12516 | 407 |
lemmas [simp del] = app_def xcpt_app_def |
408 |
||
409 |
end |