author | schirmer |
Fri, 22 Feb 2002 11:26:44 +0100 | |
changeset 12925 | 99131847fb93 |
parent 12858 | 6214f03d6d27 |
child 13337 | f75dfc606ac7 |
permissions | -rw-r--r-- |
12857 | 1 |
(* Title: HOL/Bali/State.thy |
12854 | 2 |
ID: $Id$ |
3 |
Author: David von Oheimb |
|
12858 | 4 |
License: GPL (GNU GENERAL PUBLIC LICENSE) |
12854 | 5 |
*) |
6 |
header {* State for evaluation of Java expressions and statements *} |
|
7 |
||
8 |
theory State = DeclConcepts: |
|
9 |
||
10 |
text {* |
|
11 |
design issues: |
|
12 |
\begin{itemize} |
|
13 |
\item all kinds of objects (class instances, arrays, and class objects) |
|
14 |
are handeled via a general object abstraction |
|
15 |
\item the heap and the map for class objects are combined into a single table |
|
16 |
@{text "(recall (loc, obj) table \<times> (qtname, obj) table ~= (loc + qtname, obj) table)"} |
|
17 |
\end{itemize} |
|
18 |
*} |
|
19 |
||
20 |
section "objects" |
|
21 |
||
22 |
datatype obj_tag = (* tag for generic object *) |
|
23 |
CInst qtname (* class instance *) |
|
24 |
| Arr ty int (* array with component type and length *) |
|
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
25 |
(* | CStat qtname the tag is irrelevant for a class object, |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
26 |
i.e. the static fields of a class, |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
27 |
since its type is given already by the reference to |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
28 |
it (see below) *) |
12854 | 29 |
|
30 |
types vn = "fspec + int" (* variable name *) |
|
31 |
record obj = |
|
32 |
tag :: "obj_tag" (* generalized object *) |
|
33 |
values :: "(vn, val) table" |
|
34 |
||
35 |
translations |
|
36 |
"fspec" <= (type) "vname \<times> qtname" |
|
37 |
"vn" <= (type) "fspec + int" |
|
38 |
"obj" <= (type) "\<lparr>tag::obj_tag, values::vn \<Rightarrow> val option\<rparr>" |
|
39 |
"obj" <= (type) "\<lparr>tag::obj_tag, values::vn \<Rightarrow> val option,\<dots>::'a\<rparr>" |
|
40 |
||
41 |
constdefs |
|
42 |
||
43 |
the_Arr :: "obj option \<Rightarrow> ty \<times> int \<times> (vn, val) table" |
|
44 |
"the_Arr obj \<equiv> \<epsilon>(T,k,t). obj = Some \<lparr>tag=Arr T k,values=t\<rparr>" |
|
45 |
||
46 |
lemma the_Arr_Arr [simp]: "the_Arr (Some \<lparr>tag=Arr T k,values=cs\<rparr>) = (T,k,cs)" |
|
47 |
apply (auto simp: the_Arr_def) |
|
48 |
done |
|
49 |
||
50 |
lemma the_Arr_Arr1 [simp,intro,dest]: |
|
51 |
"\<lbrakk>tag obj = Arr T k\<rbrakk> \<Longrightarrow> the_Arr (Some obj) = (T,k,values obj)" |
|
52 |
apply (auto simp add: the_Arr_def) |
|
53 |
done |
|
54 |
||
55 |
constdefs |
|
56 |
||
57 |
upd_obj :: "vn \<Rightarrow> val \<Rightarrow> obj \<Rightarrow> obj" |
|
58 |
"upd_obj n v \<equiv> \<lambda> obj . obj \<lparr>values:=(values obj)(n\<mapsto>v)\<rparr>" |
|
59 |
||
60 |
lemma upd_obj_def2 [simp]: |
|
61 |
"upd_obj n v obj = obj \<lparr>values:=(values obj)(n\<mapsto>v)\<rparr>" |
|
62 |
apply (auto simp: upd_obj_def) |
|
63 |
done |
|
64 |
||
65 |
constdefs |
|
66 |
obj_ty :: "obj \<Rightarrow> ty" |
|
67 |
"obj_ty obj \<equiv> case tag obj of |
|
68 |
CInst C \<Rightarrow> Class C |
|
69 |
| Arr T k \<Rightarrow> T.[]" |
|
70 |
||
71 |
lemma obj_ty_eq [intro!]: "obj_ty \<lparr>tag=oi,values=x\<rparr> = obj_ty \<lparr>tag=oi,values=y\<rparr>" |
|
72 |
by (simp add: obj_ty_def) |
|
73 |
||
74 |
||
75 |
lemma obj_ty_eq1 [intro!,dest]: |
|
76 |
"tag obj = tag obj' \<Longrightarrow> obj_ty obj = obj_ty obj'" |
|
77 |
by (simp add: obj_ty_def) |
|
78 |
||
79 |
lemma obj_ty_cong [simp]: |
|
80 |
"obj_ty (obj \<lparr>values:=vs\<rparr>) = obj_ty obj" |
|
81 |
by auto |
|
82 |
(* |
|
83 |
lemma obj_ty_cong [simp]: |
|
84 |
"obj_ty (obj \<lparr>values:=vs(n\<mapsto>v)\<rparr>) = obj_ty (obj \<lparr>values:=vs\<rparr>)" |
|
85 |
by auto |
|
86 |
*) |
|
87 |
lemma obj_ty_CInst [simp]: |
|
88 |
"obj_ty \<lparr>tag=CInst C,values=vs\<rparr> = Class C" |
|
89 |
by (simp add: obj_ty_def) |
|
90 |
||
91 |
lemma obj_ty_CInst1 [simp,intro!,dest]: |
|
92 |
"\<lbrakk>tag obj = CInst C\<rbrakk> \<Longrightarrow> obj_ty obj = Class C" |
|
93 |
by (simp add: obj_ty_def) |
|
94 |
||
95 |
lemma obj_ty_Arr [simp]: |
|
96 |
"obj_ty \<lparr>tag=Arr T i,values=vs\<rparr> = T.[]" |
|
97 |
by (simp add: obj_ty_def) |
|
98 |
||
99 |
lemma obj_ty_Arr1 [simp,intro!,dest]: |
|
100 |
"\<lbrakk>tag obj = Arr T i\<rbrakk> \<Longrightarrow> obj_ty obj = T.[]" |
|
101 |
by (simp add: obj_ty_def) |
|
102 |
||
103 |
lemma obj_ty_widenD: |
|
104 |
"G\<turnstile>obj_ty obj\<preceq>RefT t \<Longrightarrow> (\<exists>C. tag obj = CInst C) \<or> (\<exists>T k. tag obj = Arr T k)" |
|
105 |
apply (unfold obj_ty_def) |
|
106 |
apply (auto split add: obj_tag.split_asm) |
|
107 |
done |
|
108 |
||
109 |
constdefs |
|
110 |
||
111 |
obj_class :: "obj \<Rightarrow> qtname" |
|
112 |
"obj_class obj \<equiv> case tag obj of |
|
113 |
CInst C \<Rightarrow> C |
|
114 |
| Arr T k \<Rightarrow> Object" |
|
115 |
||
116 |
||
117 |
lemma obj_class_CInst [simp]: "obj_class \<lparr>tag=CInst C,values=vs\<rparr> = C" |
|
118 |
by (auto simp: obj_class_def) |
|
119 |
||
120 |
lemma obj_class_CInst1 [simp,intro!,dest]: |
|
121 |
"tag obj = CInst C \<Longrightarrow> obj_class obj = C" |
|
122 |
by (auto simp: obj_class_def) |
|
123 |
||
124 |
lemma obj_class_Arr [simp]: "obj_class \<lparr>tag=Arr T k,values=vs\<rparr> = Object" |
|
125 |
by (auto simp: obj_class_def) |
|
126 |
||
127 |
lemma obj_class_Arr1 [simp,intro!,dest]: |
|
128 |
"tag obj = Arr T k \<Longrightarrow> obj_class obj = Object" |
|
129 |
by (auto simp: obj_class_def) |
|
130 |
||
131 |
lemma obj_ty_obj_class: "G\<turnstile>obj_ty obj\<preceq> Class statC = G\<turnstile>obj_class obj \<preceq>\<^sub>C statC" |
|
132 |
apply (case_tac "tag obj") |
|
133 |
apply (auto simp add: obj_ty_def obj_class_def) |
|
134 |
apply (case_tac "statC = Object") |
|
135 |
apply (auto dest: widen_Array_Class) |
|
136 |
done |
|
137 |
||
138 |
section "object references" |
|
139 |
||
140 |
types oref = "loc + qtname" (* generalized object reference *) |
|
141 |
syntax |
|
142 |
Heap :: "loc \<Rightarrow> oref" |
|
143 |
Stat :: "qtname \<Rightarrow> oref" |
|
144 |
||
145 |
translations |
|
146 |
"Heap" => "Inl" |
|
147 |
"Stat" => "Inr" |
|
148 |
"oref" <= (type) "loc + qtname" |
|
149 |
||
150 |
constdefs |
|
151 |
fields_table:: |
|
152 |
"prog \<Rightarrow> qtname \<Rightarrow> (fspec \<Rightarrow> field \<Rightarrow> bool) \<Rightarrow> (fspec, ty) table" |
|
153 |
"fields_table G C P |
|
154 |
\<equiv> option_map type \<circ> table_of (filter (split P) (DeclConcepts.fields G C))" |
|
155 |
||
156 |
lemma fields_table_SomeI: |
|
157 |
"\<lbrakk>table_of (DeclConcepts.fields G C) n = Some f; P n f\<rbrakk> |
|
158 |
\<Longrightarrow> fields_table G C P n = Some (type f)" |
|
159 |
apply (unfold fields_table_def) |
|
160 |
apply clarsimp |
|
161 |
apply (rule exI) |
|
162 |
apply (rule conjI) |
|
163 |
apply (erule map_of_filter_in) |
|
164 |
apply assumption |
|
165 |
apply simp |
|
166 |
done |
|
167 |
||
168 |
(* unused *) |
|
169 |
lemma fields_table_SomeD': "fields_table G C P fn = Some T \<Longrightarrow> |
|
170 |
\<exists>f. (fn,f)\<in>set(DeclConcepts.fields G C) \<and> type f = T" |
|
171 |
apply (unfold fields_table_def) |
|
172 |
apply clarsimp |
|
173 |
apply (drule map_of_SomeD) |
|
174 |
apply auto |
|
175 |
done |
|
176 |
||
177 |
lemma fields_table_SomeD: |
|
178 |
"\<lbrakk>fields_table G C P fn = Some T; unique (DeclConcepts.fields G C)\<rbrakk> \<Longrightarrow> |
|
179 |
\<exists>f. table_of (DeclConcepts.fields G C) fn = Some f \<and> type f = T" |
|
180 |
apply (unfold fields_table_def) |
|
181 |
apply clarsimp |
|
182 |
apply (rule exI) |
|
183 |
apply (rule conjI) |
|
184 |
apply (erule table_of_filter_unique_SomeD) |
|
185 |
apply assumption |
|
186 |
apply simp |
|
187 |
done |
|
188 |
||
189 |
constdefs |
|
190 |
in_bounds :: "int \<Rightarrow> int \<Rightarrow> bool" ("(_/ in'_bounds _)" [50, 51] 50) |
|
191 |
"i in_bounds k \<equiv> 0 \<le> i \<and> i < k" |
|
192 |
||
193 |
arr_comps :: "'a \<Rightarrow> int \<Rightarrow> int \<Rightarrow> 'a option" |
|
194 |
"arr_comps T k \<equiv> \<lambda>i. if i in_bounds k then Some T else None" |
|
195 |
||
196 |
var_tys :: "prog \<Rightarrow> obj_tag \<Rightarrow> oref \<Rightarrow> (vn, ty) table" |
|
197 |
"var_tys G oi r |
|
198 |
\<equiv> case r of |
|
199 |
Heap a \<Rightarrow> (case oi of |
|
200 |
CInst C \<Rightarrow> fields_table G C (\<lambda>n f. \<not>static f) (+) empty |
|
201 |
| Arr T k \<Rightarrow> empty (+) arr_comps T k) |
|
202 |
| Stat C \<Rightarrow> fields_table G C (\<lambda>fn f. declclassf fn = C \<and> static f) |
|
203 |
(+) empty" |
|
204 |
||
205 |
lemma var_tys_Some_eq: |
|
206 |
"var_tys G oi r n = Some T |
|
207 |
= (case r of |
|
208 |
Inl a \<Rightarrow> (case oi of |
|
209 |
CInst C \<Rightarrow> (\<exists>nt. n = Inl nt \<and> fields_table G C (\<lambda>n f. |
|
210 |
\<not>static f) nt = Some T) |
|
211 |
| Arr t k \<Rightarrow> (\<exists> i. n = Inr i \<and> i in_bounds k \<and> t = T)) |
|
212 |
| Inr C \<Rightarrow> (\<exists>nt. n = Inl nt \<and> |
|
213 |
fields_table G C (\<lambda>fn f. declclassf fn = C \<and> static f) nt |
|
214 |
= Some T))" |
|
215 |
apply (unfold var_tys_def arr_comps_def) |
|
216 |
apply (force split add: sum.split_asm sum.split obj_tag.split) |
|
217 |
done |
|
218 |
||
219 |
||
220 |
section "stores" |
|
221 |
||
222 |
types globs (* global variables: heap and static variables *) |
|
223 |
= "(oref , obj) table" |
|
224 |
heap |
|
225 |
= "(loc , obj) table" |
|
226 |
locals |
|
227 |
= "(lname, val) table" (* local variables *) |
|
228 |
||
229 |
translations |
|
230 |
"globs" <= (type) "(oref , obj) table" |
|
231 |
"heap" <= (type) "(loc , obj) table" |
|
232 |
"locals" <= (type) "(lname, val) table" |
|
233 |
||
234 |
datatype st = (* pure state, i.e. contents of all variables *) |
|
235 |
st globs locals |
|
236 |
||
237 |
subsection "access" |
|
238 |
||
239 |
constdefs |
|
240 |
||
241 |
globs :: "st \<Rightarrow> globs" |
|
242 |
"globs \<equiv> st_case (\<lambda>g l. g)" |
|
243 |
||
244 |
locals :: "st \<Rightarrow> locals" |
|
245 |
"locals \<equiv> st_case (\<lambda>g l. l)" |
|
246 |
||
247 |
heap :: "st \<Rightarrow> heap" |
|
248 |
"heap s \<equiv> globs s \<circ> Heap" |
|
249 |
||
250 |
||
251 |
lemma globs_def2 [simp]: " globs (st g l) = g" |
|
252 |
by (simp add: globs_def) |
|
253 |
||
254 |
lemma locals_def2 [simp]: "locals (st g l) = l" |
|
255 |
by (simp add: locals_def) |
|
256 |
||
257 |
lemma heap_def2 [simp]: "heap s a=globs s (Heap a)" |
|
258 |
by (simp add: heap_def) |
|
259 |
||
260 |
||
261 |
syntax |
|
262 |
val_this :: "st \<Rightarrow> val" |
|
263 |
lookup_obj :: "st \<Rightarrow> val \<Rightarrow> obj" |
|
264 |
||
265 |
translations |
|
266 |
"val_this s" == "the (locals s This)" |
|
267 |
"lookup_obj s a'" == "the (heap s (the_Addr a'))" |
|
268 |
||
269 |
subsection "memory allocation" |
|
270 |
||
271 |
constdefs |
|
272 |
new_Addr :: "heap \<Rightarrow> loc option" |
|
273 |
"new_Addr h \<equiv> if (\<forall>a. h a \<noteq> None) then None else Some (\<epsilon>a. h a = None)" |
|
274 |
||
275 |
lemma new_AddrD: "new_Addr h = Some a \<Longrightarrow> h a = None" |
|
276 |
apply (unfold new_Addr_def) |
|
277 |
apply auto |
|
278 |
apply (case_tac "h (SOME a\<Colon>loc. h a = None)") |
|
279 |
apply simp |
|
280 |
apply (fast intro: someI2) |
|
281 |
done |
|
282 |
||
283 |
lemma new_AddrD2: "new_Addr h = Some a \<Longrightarrow> \<forall>b. h b \<noteq> None \<longrightarrow> b \<noteq> a" |
|
284 |
apply (drule new_AddrD) |
|
285 |
apply auto |
|
286 |
done |
|
287 |
||
288 |
lemma new_Addr_SomeI: "h a = None \<Longrightarrow> \<exists>b. new_Addr h = Some b \<and> h b = None" |
|
289 |
apply (unfold new_Addr_def) |
|
290 |
apply (frule not_Some_eq [THEN iffD2]) |
|
291 |
apply auto |
|
292 |
apply (drule not_Some_eq [THEN iffD2]) |
|
293 |
apply auto |
|
294 |
apply (fast intro!: someI2) |
|
295 |
done |
|
296 |
||
297 |
||
298 |
subsection "initialization" |
|
299 |
||
300 |
syntax |
|
301 |
||
302 |
init_vals :: "('a, ty) table \<Rightarrow> ('a, val) table" |
|
303 |
||
304 |
translations |
|
305 |
"init_vals vs" == "option_map default_val \<circ> vs" |
|
306 |
||
307 |
lemma init_arr_comps_base [simp]: "init_vals (arr_comps T 0) = empty" |
|
308 |
apply (unfold arr_comps_def in_bounds_def) |
|
309 |
apply (rule ext) |
|
310 |
apply auto |
|
311 |
done |
|
312 |
||
313 |
lemma init_arr_comps_step [simp]: |
|
314 |
"0 < j \<Longrightarrow> init_vals (arr_comps T j ) = |
|
315 |
init_vals (arr_comps T (j - 1))(j - 1\<mapsto>default_val T)" |
|
316 |
apply (unfold arr_comps_def in_bounds_def) |
|
317 |
apply (rule ext) |
|
318 |
apply auto |
|
319 |
done |
|
320 |
||
321 |
subsection "update" |
|
322 |
||
323 |
constdefs |
|
324 |
gupd :: "oref \<Rightarrow> obj \<Rightarrow> st \<Rightarrow> st" ("gupd'(_\<mapsto>_')"[10,10]1000) |
|
325 |
"gupd r obj \<equiv> st_case (\<lambda>g l. st (g(r\<mapsto>obj)) l)" |
|
326 |
||
327 |
lupd :: "lname \<Rightarrow> val \<Rightarrow> st \<Rightarrow> st" ("lupd'(_\<mapsto>_')"[10,10]1000) |
|
328 |
"lupd vn v \<equiv> st_case (\<lambda>g l. st g (l(vn\<mapsto>v)))" |
|
329 |
||
330 |
upd_gobj :: "oref \<Rightarrow> vn \<Rightarrow> val \<Rightarrow> st \<Rightarrow> st" |
|
331 |
"upd_gobj r n v \<equiv> st_case (\<lambda>g l. st (chg_map (upd_obj n v) r g) l)" |
|
332 |
||
333 |
set_locals :: "locals \<Rightarrow> st \<Rightarrow> st" |
|
334 |
"set_locals l \<equiv> st_case (\<lambda>g l'. st g l)" |
|
335 |
||
336 |
init_obj :: "prog \<Rightarrow> obj_tag \<Rightarrow> oref \<Rightarrow> st \<Rightarrow> st" |
|
337 |
"init_obj G oi r \<equiv> gupd(r\<mapsto>\<lparr>tag=oi, values=init_vals (var_tys G oi r)\<rparr>)" |
|
338 |
||
339 |
syntax |
|
340 |
init_class_obj :: "prog \<Rightarrow> qtname \<Rightarrow> st \<Rightarrow> st" |
|
341 |
||
342 |
translations |
|
343 |
"init_class_obj G C" == "init_obj G arbitrary (Inr C)" |
|
344 |
||
345 |
lemma gupd_def2 [simp]: "gupd(r\<mapsto>obj) (st g l) = st (g(r\<mapsto>obj)) l" |
|
346 |
apply (unfold gupd_def) |
|
347 |
apply (simp (no_asm)) |
|
348 |
done |
|
349 |
||
350 |
lemma lupd_def2 [simp]: "lupd(vn\<mapsto>v) (st g l) = st g (l(vn\<mapsto>v))" |
|
351 |
apply (unfold lupd_def) |
|
352 |
apply (simp (no_asm)) |
|
353 |
done |
|
354 |
||
355 |
lemma globs_gupd [simp]: "globs (gupd(r\<mapsto>obj) s) = globs s(r\<mapsto>obj)" |
|
356 |
apply (induct "s") |
|
357 |
by (simp add: gupd_def) |
|
358 |
||
359 |
lemma globs_lupd [simp]: "globs (lupd(vn\<mapsto>v ) s) = globs s" |
|
360 |
apply (induct "s") |
|
361 |
by (simp add: lupd_def) |
|
362 |
||
363 |
lemma locals_gupd [simp]: "locals (gupd(r\<mapsto>obj) s) = locals s" |
|
364 |
apply (induct "s") |
|
365 |
by (simp add: gupd_def) |
|
366 |
||
367 |
lemma locals_lupd [simp]: "locals (lupd(vn\<mapsto>v ) s) = locals s(vn\<mapsto>v )" |
|
368 |
apply (induct "s") |
|
369 |
by (simp add: lupd_def) |
|
370 |
||
371 |
lemma globs_upd_gobj_new [rule_format (no_asm), simp]: |
|
372 |
"globs s r = None \<longrightarrow> globs (upd_gobj r n v s) = globs s" |
|
373 |
apply (unfold upd_gobj_def) |
|
374 |
apply (induct "s") |
|
375 |
apply auto |
|
376 |
done |
|
377 |
||
378 |
lemma globs_upd_gobj_upd [rule_format (no_asm), simp]: |
|
379 |
"globs s r=Some obj\<longrightarrow> globs (upd_gobj r n v s) = globs s(r\<mapsto>upd_obj n v obj)" |
|
380 |
apply (unfold upd_gobj_def) |
|
381 |
apply (induct "s") |
|
382 |
apply auto |
|
383 |
done |
|
384 |
||
385 |
lemma locals_upd_gobj [simp]: "locals (upd_gobj r n v s) = locals s" |
|
386 |
apply (induct "s") |
|
387 |
by (simp add: upd_gobj_def) |
|
388 |
||
389 |
||
390 |
lemma globs_init_obj [simp]: "globs (init_obj G oi r s) t = |
|
391 |
(if t=r then Some \<lparr>tag=oi,values=init_vals (var_tys G oi r)\<rparr> else globs s t)" |
|
392 |
apply (unfold init_obj_def) |
|
393 |
apply (simp (no_asm)) |
|
394 |
done |
|
395 |
||
396 |
lemma locals_init_obj [simp]: "locals (init_obj G oi r s) = locals s" |
|
397 |
by (simp add: init_obj_def) |
|
398 |
||
399 |
lemma surjective_st [simp]: "st (globs s) (locals s) = s" |
|
400 |
apply (induct "s") |
|
401 |
by auto |
|
402 |
||
403 |
lemma surjective_st_init_obj: |
|
404 |
"st (globs (init_obj G oi r s)) (locals s) = init_obj G oi r s" |
|
405 |
apply (subst locals_init_obj [THEN sym]) |
|
406 |
apply (rule surjective_st) |
|
407 |
done |
|
408 |
||
409 |
lemma heap_heap_upd [simp]: |
|
410 |
"heap (st (g(Inl a\<mapsto>obj)) l) = heap (st g l)(a\<mapsto>obj)" |
|
411 |
apply (rule ext) |
|
412 |
apply (simp (no_asm)) |
|
413 |
done |
|
414 |
lemma heap_stat_upd [simp]: "heap (st (g(Inr C\<mapsto>obj)) l) = heap (st g l)" |
|
415 |
apply (rule ext) |
|
416 |
apply (simp (no_asm)) |
|
417 |
done |
|
418 |
lemma heap_local_upd [simp]: "heap (st g (l(vn\<mapsto>v))) = heap (st g l)" |
|
419 |
apply (rule ext) |
|
420 |
apply (simp (no_asm)) |
|
421 |
done |
|
422 |
||
423 |
lemma heap_gupd_Heap [simp]: "heap (gupd(Heap a\<mapsto>obj) s) = heap s(a\<mapsto>obj)" |
|
424 |
apply (rule ext) |
|
425 |
apply (simp (no_asm)) |
|
426 |
done |
|
427 |
lemma heap_gupd_Stat [simp]: "heap (gupd(Stat C\<mapsto>obj) s) = heap s" |
|
428 |
apply (rule ext) |
|
429 |
apply (simp (no_asm)) |
|
430 |
done |
|
431 |
lemma heap_lupd [simp]: "heap (lupd(vn\<mapsto>v) s) = heap s" |
|
432 |
apply (rule ext) |
|
433 |
apply (simp (no_asm)) |
|
434 |
done |
|
435 |
||
436 |
(* |
|
437 |
lemma heap_upd_gobj_Heap: "!!a. heap (upd_gobj (Heap a) n v s) = ?X" |
|
438 |
apply (rule ext) |
|
439 |
apply (simp (no_asm)) |
|
440 |
apply (case_tac "globs s (Heap a)") |
|
441 |
apply auto |
|
442 |
*) |
|
443 |
||
444 |
lemma heap_upd_gobj_Stat [simp]: "heap (upd_gobj (Stat C) n v s) = heap s" |
|
445 |
apply (rule ext) |
|
446 |
apply (simp (no_asm)) |
|
447 |
apply (case_tac "globs s (Stat C)") |
|
448 |
apply auto |
|
449 |
done |
|
450 |
||
451 |
lemma set_locals_def2 [simp]: "set_locals l (st g l') = st g l" |
|
452 |
apply (unfold set_locals_def) |
|
453 |
apply (simp (no_asm)) |
|
454 |
done |
|
455 |
||
456 |
lemma set_locals_id [simp]: "set_locals (locals s) s = s" |
|
457 |
apply (unfold set_locals_def) |
|
458 |
apply (induct_tac "s") |
|
459 |
apply (simp (no_asm)) |
|
460 |
done |
|
461 |
||
462 |
lemma set_set_locals [simp]: "set_locals l (set_locals l' s) = set_locals l s" |
|
463 |
apply (unfold set_locals_def) |
|
464 |
apply (induct_tac "s") |
|
465 |
apply (simp (no_asm)) |
|
466 |
done |
|
467 |
||
468 |
lemma locals_set_locals [simp]: "locals (set_locals l s) = l" |
|
469 |
apply (unfold set_locals_def) |
|
470 |
apply (induct_tac "s") |
|
471 |
apply (simp (no_asm)) |
|
472 |
done |
|
473 |
||
474 |
lemma globs_set_locals [simp]: "globs (set_locals l s) = globs s" |
|
475 |
apply (unfold set_locals_def) |
|
476 |
apply (induct_tac "s") |
|
477 |
apply (simp (no_asm)) |
|
478 |
done |
|
479 |
||
480 |
lemma heap_set_locals [simp]: "heap (set_locals l s) = heap s" |
|
481 |
apply (unfold heap_def) |
|
482 |
apply (induct_tac "s") |
|
483 |
apply (simp (no_asm)) |
|
484 |
done |
|
485 |
||
486 |
||
487 |
section "abrupt completion" |
|
488 |
||
489 |
||
490 |
datatype xcpt (* exception *) |
|
491 |
= Loc loc (* location of allocated execption object *) |
|
492 |
| Std xname (* intermediate standard exception, see Eval.thy *) |
|
493 |
||
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
494 |
datatype error |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
495 |
= AccessViolation (* Access to a member that isn't permitted *) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
496 |
|
12854 | 497 |
datatype abrupt (* abrupt completion *) |
498 |
= Xcpt xcpt (* exception *) |
|
499 |
| Jump jump (* break, continue, return *) |
|
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
500 |
| Error error (* runtime errors, we wan't to detect and proof absent |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
501 |
in welltyped programms *) |
12854 | 502 |
consts |
503 |
||
504 |
the_Xcpt :: "abrupt \<Rightarrow> xcpt" |
|
505 |
the_Jump :: "abrupt => jump" |
|
506 |
the_Loc :: "xcpt \<Rightarrow> loc" |
|
507 |
the_Std :: "xcpt \<Rightarrow> xname" |
|
508 |
||
509 |
primrec "the_Xcpt (Xcpt x) = x" |
|
510 |
primrec "the_Jump (Jump j) = j" |
|
511 |
primrec "the_Loc (Loc a) = a" |
|
512 |
primrec "the_Std (Std x) = x" |
|
513 |
||
514 |
types |
|
515 |
abopt = "abrupt option" |
|
516 |
||
517 |
||
518 |
constdefs |
|
519 |
abrupt_if :: "bool \<Rightarrow> abopt \<Rightarrow> abopt \<Rightarrow> abopt" |
|
520 |
"abrupt_if c x' x \<equiv> if c \<and> (x = None) then x' else x" |
|
521 |
||
522 |
lemma abrupt_if_True_None [simp]: "abrupt_if True x None = x" |
|
523 |
by (simp add: abrupt_if_def) |
|
524 |
||
525 |
lemma abrupt_if_True_not_None [simp]: "x \<noteq> None \<Longrightarrow> abrupt_if True x y \<noteq> None" |
|
526 |
by (simp add: abrupt_if_def) |
|
527 |
||
528 |
lemma abrupt_if_False [simp]: "abrupt_if False x y = y" |
|
529 |
by (simp add: abrupt_if_def) |
|
530 |
||
531 |
lemma abrupt_if_Some [simp]: "abrupt_if c x (Some y) = Some y" |
|
532 |
by (simp add: abrupt_if_def) |
|
533 |
||
534 |
lemma abrupt_if_not_None [simp]: "y \<noteq> None \<Longrightarrow> abrupt_if c x y = y" |
|
535 |
apply (simp add: abrupt_if_def) |
|
536 |
by auto |
|
537 |
||
538 |
||
539 |
lemma split_abrupt_if: |
|
540 |
"P (abrupt_if c x' x) = |
|
541 |
((c \<and> x = None \<longrightarrow> P x') \<and> (\<not> (c \<and> x = None) \<longrightarrow> P x))" |
|
542 |
apply (unfold abrupt_if_def) |
|
543 |
apply (split split_if) |
|
544 |
apply auto |
|
545 |
done |
|
546 |
||
547 |
syntax |
|
548 |
||
549 |
raise_if :: "bool \<Rightarrow> xname \<Rightarrow> abopt \<Rightarrow> abopt" |
|
550 |
np :: "val \<spacespace> \<Rightarrow> abopt \<Rightarrow> abopt" |
|
551 |
check_neg:: "val \<spacespace> \<Rightarrow> abopt \<Rightarrow> abopt" |
|
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
552 |
error_if :: "bool \<Rightarrow> error \<Rightarrow> abopt \<Rightarrow> abopt" |
12854 | 553 |
|
554 |
translations |
|
555 |
||
556 |
"raise_if c xn" == "abrupt_if c (Some (Xcpt (Std xn)))" |
|
557 |
"np v" == "raise_if (v = Null) NullPointer" |
|
558 |
"check_neg i'" == "raise_if (the_Intg i'<0) NegArrSize" |
|
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
559 |
"error_if c e" == "abrupt_if c (Some (Error e))" |
12854 | 560 |
|
561 |
lemma raise_if_None [simp]: "(raise_if c x y = None) = (\<not>c \<and> y = None)" |
|
562 |
apply (simp add: abrupt_if_def) |
|
563 |
by auto |
|
564 |
declare raise_if_None [THEN iffD1, dest!] |
|
565 |
||
566 |
lemma if_raise_if_None [simp]: |
|
567 |
"((if b then y else raise_if c x y) = None) = ((c \<longrightarrow> b) \<and> y = None)" |
|
568 |
apply (simp add: abrupt_if_def) |
|
569 |
apply auto |
|
570 |
done |
|
571 |
||
572 |
lemma raise_if_SomeD [dest!]: |
|
573 |
"raise_if c x y = Some z \<Longrightarrow> c \<and> z=(Xcpt (Std x)) \<and> y=None \<or> (y=Some z)" |
|
574 |
apply (case_tac y) |
|
575 |
apply (case_tac c) |
|
576 |
apply (simp add: abrupt_if_def) |
|
577 |
apply (simp add: abrupt_if_def) |
|
578 |
apply auto |
|
579 |
done |
|
580 |
||
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
581 |
lemma error_if_None [simp]: "(error_if c e y = None) = (\<not>c \<and> y = None)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
582 |
apply (simp add: abrupt_if_def) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
583 |
by auto |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
584 |
declare error_if_None [THEN iffD1, dest!] |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
585 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
586 |
lemma if_error_if_None [simp]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
587 |
"((if b then y else error_if c e y) = None) = ((c \<longrightarrow> b) \<and> y = None)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
588 |
apply (simp add: abrupt_if_def) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
589 |
apply auto |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
590 |
done |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
591 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
592 |
lemma raise_if_SomeD [dest!]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
593 |
"error_if c e y = Some z \<Longrightarrow> c \<and> z=(Error e) \<and> y=None \<or> (y=Some z)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
594 |
apply (case_tac y) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
595 |
apply (case_tac c) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
596 |
apply (simp add: abrupt_if_def) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
597 |
apply (simp add: abrupt_if_def) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
598 |
apply auto |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
599 |
done |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
600 |
|
12854 | 601 |
constdefs |
602 |
absorb :: "jump \<Rightarrow> abopt \<Rightarrow> abopt" |
|
603 |
"absorb j a \<equiv> if a=Some (Jump j) then None else a" |
|
604 |
||
605 |
lemma absorb_SomeD [dest!]: "absorb j a = Some x \<Longrightarrow> a = Some x" |
|
606 |
by (auto simp add: absorb_def) |
|
607 |
||
608 |
lemma absorb_same [simp]: "absorb j (Some (Jump j)) = None" |
|
609 |
by (auto simp add: absorb_def) |
|
610 |
||
611 |
lemma absorb_other [simp]: "a \<noteq> Some (Jump j) \<Longrightarrow> absorb j a = a" |
|
612 |
by (auto simp add: absorb_def) |
|
613 |
||
614 |
||
615 |
section "full program state" |
|
616 |
||
617 |
types |
|
618 |
state = "abopt \<times> st" (* state including exception information *) |
|
619 |
||
620 |
syntax |
|
621 |
Norm :: "st \<Rightarrow> state" |
|
622 |
abrupt :: "state \<Rightarrow> abopt" |
|
623 |
store :: "state \<Rightarrow> st" |
|
624 |
||
625 |
translations |
|
626 |
||
627 |
"Norm s" == "(None,s)" |
|
628 |
"abrupt" => "fst" |
|
629 |
"store" => "snd" |
|
630 |
"abopt" <= (type) "State.abrupt option" |
|
631 |
"abopt" <= (type) "abrupt option" |
|
632 |
"state" <= (type) "abopt \<times> State.st" |
|
633 |
"state" <= (type) "abopt \<times> st" |
|
634 |
||
635 |
||
636 |
||
637 |
lemma single_stateE: "\<forall>Z. Z = (s::state) \<Longrightarrow> False" |
|
638 |
apply (erule_tac x = "(Some k,y)" in all_dupE) |
|
639 |
apply (erule_tac x = "(None,y)" in allE) |
|
640 |
apply clarify |
|
641 |
done |
|
642 |
||
643 |
lemma state_not_single: "All (op = (x::state)) \<Longrightarrow> R" |
|
644 |
apply (drule_tac x = "(if abrupt x = None then Some ?x else None,?y)" in spec) |
|
645 |
apply clarsimp |
|
646 |
done |
|
647 |
||
648 |
constdefs |
|
649 |
||
650 |
normal :: "state \<Rightarrow> bool" |
|
651 |
"normal \<equiv> \<lambda>s. abrupt s = None" |
|
652 |
||
653 |
lemma normal_def2 [simp]: "normal s = (abrupt s = None)" |
|
654 |
apply (unfold normal_def) |
|
655 |
apply (simp (no_asm)) |
|
656 |
done |
|
657 |
||
658 |
constdefs |
|
659 |
heap_free :: "nat \<Rightarrow> state \<Rightarrow> bool" |
|
660 |
"heap_free n \<equiv> \<lambda>s. atleast_free (heap (store s)) n" |
|
661 |
||
662 |
lemma heap_free_def2 [simp]: "heap_free n s = atleast_free (heap (store s)) n" |
|
663 |
apply (unfold heap_free_def) |
|
664 |
apply simp |
|
665 |
done |
|
666 |
||
667 |
subsection "update" |
|
668 |
||
669 |
constdefs |
|
670 |
||
671 |
abupd :: "(abopt \<Rightarrow> abopt) \<Rightarrow> state \<Rightarrow> state" |
|
672 |
"abupd f \<equiv> prod_fun f id" |
|
673 |
||
674 |
supd :: "(st \<Rightarrow> st) \<Rightarrow> state \<Rightarrow> state" |
|
675 |
"supd \<equiv> prod_fun id" |
|
676 |
||
677 |
lemma abupd_def2 [simp]: "abupd f (x,s) = (f x,s)" |
|
678 |
by (simp add: abupd_def) |
|
679 |
||
680 |
lemma abupd_abrupt_if_False [simp]: "\<And> s. abupd (abrupt_if False xo) s = s" |
|
681 |
by simp |
|
682 |
||
683 |
lemma supd_def2 [simp]: "supd f (x,s) = (x,f s)" |
|
684 |
by (simp add: supd_def) |
|
685 |
||
686 |
lemma supd_lupd [simp]: |
|
687 |
"\<And> s. supd (lupd vn v ) s = (abrupt s,lupd vn v (store s))" |
|
688 |
apply (simp (no_asm_simp) only: split_tupled_all) |
|
689 |
apply (simp (no_asm)) |
|
690 |
done |
|
691 |
||
692 |
||
693 |
lemma supd_gupd [simp]: |
|
694 |
"\<And> s. supd (gupd r obj) s = (abrupt s,gupd r obj (store s))" |
|
695 |
apply (simp (no_asm_simp) only: split_tupled_all) |
|
696 |
apply (simp (no_asm)) |
|
697 |
done |
|
698 |
||
699 |
lemma supd_init_obj [simp]: |
|
700 |
"supd (init_obj G oi r) s = (abrupt s,init_obj G oi r (store s))" |
|
701 |
apply (unfold init_obj_def) |
|
702 |
apply (simp (no_asm)) |
|
703 |
done |
|
704 |
||
705 |
syntax |
|
706 |
||
707 |
set_lvars :: "locals \<Rightarrow> state \<Rightarrow> state" |
|
708 |
restore_lvars :: "state \<Rightarrow> state \<Rightarrow> state" |
|
709 |
||
710 |
translations |
|
711 |
||
712 |
"set_lvars l" == "supd (set_locals l)" |
|
713 |
"restore_lvars s' s" == "set_lvars (locals (store s')) s" |
|
714 |
||
715 |
lemma set_set_lvars [simp]: "\<And> s. set_lvars l (set_lvars l' s) = set_lvars l s" |
|
716 |
apply (simp (no_asm_simp) only: split_tupled_all) |
|
717 |
apply (simp (no_asm)) |
|
718 |
done |
|
719 |
||
720 |
lemma set_lvars_id [simp]: "\<And> s. set_lvars (locals (store s)) s = s" |
|
721 |
apply (simp (no_asm_simp) only: split_tupled_all) |
|
722 |
apply (simp (no_asm)) |
|
723 |
done |
|
724 |
||
725 |
section "initialisation test" |
|
726 |
||
727 |
constdefs |
|
728 |
||
729 |
inited :: "qtname \<Rightarrow> globs \<Rightarrow> bool" |
|
730 |
"inited C g \<equiv> g (Stat C) \<noteq> None" |
|
731 |
||
732 |
initd :: "qtname \<Rightarrow> state \<Rightarrow> bool" |
|
733 |
"initd C \<equiv> inited C \<circ> globs \<circ> store" |
|
734 |
||
735 |
lemma not_inited_empty [simp]: "\<not>inited C empty" |
|
736 |
apply (unfold inited_def) |
|
737 |
apply (simp (no_asm)) |
|
738 |
done |
|
739 |
||
740 |
lemma inited_gupdate [simp]: "inited C (g(r\<mapsto>obj)) = (inited C g \<or> r = Stat C)" |
|
741 |
apply (unfold inited_def) |
|
742 |
apply (auto split add: st.split) |
|
743 |
done |
|
744 |
||
745 |
lemma inited_init_class_obj [intro!]: "inited C (globs (init_class_obj G C s))" |
|
746 |
apply (unfold inited_def) |
|
747 |
apply (simp (no_asm)) |
|
748 |
done |
|
749 |
||
750 |
lemma not_initedD: "\<not> inited C g \<Longrightarrow> g (Stat C) = None" |
|
751 |
apply (unfold inited_def) |
|
752 |
apply (erule notnotD) |
|
753 |
done |
|
754 |
||
755 |
lemma initedD: "inited C g \<Longrightarrow> \<exists> obj. g (Stat C) = Some obj" |
|
756 |
apply (unfold inited_def) |
|
757 |
apply auto |
|
758 |
done |
|
759 |
||
760 |
lemma initd_def2 [simp]: "initd C s = inited C (globs (store s))" |
|
761 |
apply (unfold initd_def) |
|
762 |
apply (simp (no_asm)) |
|
763 |
done |
|
764 |
||
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
765 |
section {* @{text error_free} *} |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
766 |
constdefs error_free:: "state \<Rightarrow> bool" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
767 |
"error_free s \<equiv> \<not> (\<exists> err. abrupt s = Some (Error err))" |
12854 | 768 |
|
12925
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
769 |
lemma error_free_Norm [simp,intro]: "error_free (Norm s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
770 |
by (simp add: error_free_def) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
771 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
772 |
lemma error_free_normal [simp,intro]: "normal s \<Longrightarrow> error_free s" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
773 |
by (simp add: error_free_def) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
774 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
775 |
lemma error_free_Xcpt [simp]: "error_free (Some (Xcpt x),s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
776 |
by (simp add: error_free_def) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
777 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
778 |
lemma error_free_Jump [simp,intro]: "error_free (Some (Jump j),s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
779 |
by (simp add: error_free_def) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
780 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
781 |
lemma error_free_Error [simp]: "error_free (Some (Error e),s) = False" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
782 |
by (simp add: error_free_def) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
783 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
784 |
lemma error_free_Some [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
785 |
"\<not> (\<exists> err. x=Error err) \<Longrightarrow> error_free ((Some x),s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
786 |
by (auto simp add: error_free_def) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
787 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
788 |
lemma error_free_absorb [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
789 |
"error_free s \<Longrightarrow> error_free (abupd (absorb j) s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
790 |
by (cases s) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
791 |
(auto simp add: error_free_def absorb_def |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
792 |
split: split_if_asm) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
793 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
794 |
lemma error_free_absorb [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
795 |
"error_free (a,s) \<Longrightarrow> error_free (absorb j a, s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
796 |
by (auto simp add: error_free_def absorb_def |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
797 |
split: split_if_asm) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
798 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
799 |
lemma error_free_abrupt_if [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
800 |
"\<lbrakk>error_free s; \<not> (\<exists> err. x=Error err)\<rbrakk> |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
801 |
\<Longrightarrow> error_free (abupd (abrupt_if p (Some x)) s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
802 |
by (cases s) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
803 |
(auto simp add: abrupt_if_def |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
804 |
split: split_if) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
805 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
806 |
lemma error_free_abrupt_if1 [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
807 |
"\<lbrakk>error_free (a,s); \<not> (\<exists> err. x=Error err)\<rbrakk> |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
808 |
\<Longrightarrow> error_free (abrupt_if p (Some x) a, s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
809 |
by (auto simp add: abrupt_if_def |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
810 |
split: split_if) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
811 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
812 |
lemma error_free_abrupt_if_Xcpt [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
813 |
"error_free s |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
814 |
\<Longrightarrow> error_free (abupd (abrupt_if p (Some (Xcpt x))) s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
815 |
by simp |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
816 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
817 |
lemma error_free_abrupt_if_Xcpt1 [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
818 |
"error_free (a,s) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
819 |
\<Longrightarrow> error_free (abrupt_if p (Some (Xcpt x)) a, s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
820 |
by simp |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
821 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
822 |
lemma error_free_abrupt_if_Jump [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
823 |
"error_free s |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
824 |
\<Longrightarrow> error_free (abupd (abrupt_if p (Some (Jump j))) s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
825 |
by simp |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
826 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
827 |
lemma error_free_abrupt_if_Jump1 [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
828 |
"error_free (a,s) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
829 |
\<Longrightarrow> error_free (abrupt_if p (Some (Jump j)) a, s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
830 |
by simp |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
831 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
832 |
lemma error_free_raise_if [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
833 |
"error_free s \<Longrightarrow> error_free (abupd (raise_if p x) s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
834 |
by simp |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
835 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
836 |
lemma error_free_raise_if1 [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
837 |
"error_free (a,s) \<Longrightarrow> error_free ((raise_if p x a), s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
838 |
by simp |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
839 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
840 |
lemma error_free_supd [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
841 |
"error_free s \<Longrightarrow> error_free (supd f s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
842 |
by (cases s) (simp add: error_free_def) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
843 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
844 |
lemma error_free_supd1 [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
845 |
"error_free (a,s) \<Longrightarrow> error_free (a,f s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
846 |
by (simp add: error_free_def) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
847 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
848 |
lemma error_free_set_lvars [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
849 |
"error_free s \<Longrightarrow> error_free ((set_lvars l) s)" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
850 |
by (cases s) simp |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
851 |
|
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
852 |
lemma error_free_set_locals [simp,intro]: |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
853 |
"error_free (x, s) |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
854 |
\<Longrightarrow> error_free (x, set_locals l s')" |
99131847fb93
Added check for field/method access to operational semantics and proved the acesses valid.
schirmer
parents:
12858
diff
changeset
|
855 |
by (simp add: error_free_def) |
12854 | 856 |
|
857 |
end |
|
858 |