61 types 'a assn = "res \<Rightarrow> state \<Rightarrow> 'a \<Rightarrow> bool" |
61 types 'a assn = "res \<Rightarrow> state \<Rightarrow> 'a \<Rightarrow> bool" |
62 translations |
62 translations |
63 "res" <= (type) "AxSem.res" |
63 "res" <= (type) "AxSem.res" |
64 "a assn" <= (type) "vals \<Rightarrow> state \<Rightarrow> a \<Rightarrow> bool" |
64 "a assn" <= (type) "vals \<Rightarrow> state \<Rightarrow> a \<Rightarrow> bool" |
65 |
65 |
66 constdefs |
66 definition assn_imp :: "'a assn \<Rightarrow> 'a assn \<Rightarrow> bool" (infixr "\<Rightarrow>" 25) where |
67 assn_imp :: "'a assn \<Rightarrow> 'a assn \<Rightarrow> bool" (infixr "\<Rightarrow>" 25) |
|
68 "P \<Rightarrow> Q \<equiv> \<forall>Y s Z. P Y s Z \<longrightarrow> Q Y s Z" |
67 "P \<Rightarrow> Q \<equiv> \<forall>Y s Z. P Y s Z \<longrightarrow> Q Y s Z" |
69 |
68 |
70 lemma assn_imp_def2 [iff]: "(P \<Rightarrow> Q) = (\<forall>Y s Z. P Y s Z \<longrightarrow> Q Y s Z)" |
69 lemma assn_imp_def2 [iff]: "(P \<Rightarrow> Q) = (\<forall>Y s Z. P Y s Z \<longrightarrow> Q Y s Z)" |
71 apply (unfold assn_imp_def) |
70 apply (unfold assn_imp_def) |
72 apply (rule HOL.refl) |
71 apply (rule HOL.refl) |
75 |
74 |
76 section "assertion transformers" |
75 section "assertion transformers" |
77 |
76 |
78 subsection "peek-and" |
77 subsection "peek-and" |
79 |
78 |
80 constdefs |
79 definition peek_and :: "'a assn \<Rightarrow> (state \<Rightarrow> bool) \<Rightarrow> 'a assn" (infixl "\<and>." 13) where |
81 peek_and :: "'a assn \<Rightarrow> (state \<Rightarrow> bool) \<Rightarrow> 'a assn" (infixl "\<and>." 13) |
|
82 "P \<and>. p \<equiv> \<lambda>Y s Z. P Y s Z \<and> p s" |
80 "P \<and>. p \<equiv> \<lambda>Y s Z. P Y s Z \<and> p s" |
83 |
81 |
84 lemma peek_and_def2 [simp]: "peek_and P p Y s = (\<lambda>Z. (P Y s Z \<and> p s))" |
82 lemma peek_and_def2 [simp]: "peek_and P p Y s = (\<lambda>Z. (P Y s Z \<and> p s))" |
85 apply (unfold peek_and_def) |
83 apply (unfold peek_and_def) |
86 apply (simp (no_asm)) |
84 apply (simp (no_asm)) |
115 apply auto |
113 apply auto |
116 done |
114 done |
117 |
115 |
118 subsection "assn-supd" |
116 subsection "assn-supd" |
119 |
117 |
120 constdefs |
118 definition assn_supd :: "'a assn \<Rightarrow> (state \<Rightarrow> state) \<Rightarrow> 'a assn" (infixl ";." 13) where |
121 assn_supd :: "'a assn \<Rightarrow> (state \<Rightarrow> state) \<Rightarrow> 'a assn" (infixl ";." 13) |
|
122 "P ;. f \<equiv> \<lambda>Y s' Z. \<exists>s. P Y s Z \<and> s' = f s" |
119 "P ;. f \<equiv> \<lambda>Y s' Z. \<exists>s. P Y s Z \<and> s' = f s" |
123 |
120 |
124 lemma assn_supd_def2 [simp]: "assn_supd P f Y s' Z = (\<exists>s. P Y s Z \<and> s' = f s)" |
121 lemma assn_supd_def2 [simp]: "assn_supd P f Y s' Z = (\<exists>s. P Y s Z \<and> s' = f s)" |
125 apply (unfold assn_supd_def) |
122 apply (unfold assn_supd_def) |
126 apply (simp (no_asm)) |
123 apply (simp (no_asm)) |
127 done |
124 done |
128 |
125 |
129 subsection "supd-assn" |
126 subsection "supd-assn" |
130 |
127 |
131 constdefs |
128 definition supd_assn :: "(state \<Rightarrow> state) \<Rightarrow> 'a assn \<Rightarrow> 'a assn" (infixr ".;" 13) where |
132 supd_assn :: "(state \<Rightarrow> state) \<Rightarrow> 'a assn \<Rightarrow> 'a assn" (infixr ".;" 13) |
|
133 "f .; P \<equiv> \<lambda>Y s. P Y (f s)" |
129 "f .; P \<equiv> \<lambda>Y s. P Y (f s)" |
134 |
130 |
135 |
131 |
136 lemma supd_assn_def2 [simp]: "(f .; P) Y s = P Y (f s)" |
132 lemma supd_assn_def2 [simp]: "(f .; P) Y s = P Y (f s)" |
137 apply (unfold supd_assn_def) |
133 apply (unfold supd_assn_def) |
146 apply (auto simp del: split_paired_Ex) |
142 apply (auto simp del: split_paired_Ex) |
147 done |
143 done |
148 |
144 |
149 subsection "subst-res" |
145 subsection "subst-res" |
150 |
146 |
151 constdefs |
147 definition subst_res :: "'a assn \<Rightarrow> res \<Rightarrow> 'a assn" ("_\<leftarrow>_" [60,61] 60) where |
152 subst_res :: "'a assn \<Rightarrow> res \<Rightarrow> 'a assn" ("_\<leftarrow>_" [60,61] 60) |
|
153 "P\<leftarrow>w \<equiv> \<lambda>Y. P w" |
148 "P\<leftarrow>w \<equiv> \<lambda>Y. P w" |
154 |
149 |
155 lemma subst_res_def2 [simp]: "(P\<leftarrow>w) Y = P w" |
150 lemma subst_res_def2 [simp]: "(P\<leftarrow>w) Y = P w" |
156 apply (unfold subst_res_def) |
151 apply (unfold subst_res_def) |
157 apply (simp (no_asm)) |
152 apply (simp (no_asm)) |
182 by simp |
177 by simp |
183 *) |
178 *) |
184 |
179 |
185 subsection "subst-Bool" |
180 subsection "subst-Bool" |
186 |
181 |
187 constdefs |
182 definition subst_Bool :: "'a assn \<Rightarrow> bool \<Rightarrow> 'a assn" ("_\<leftarrow>=_" [60,61] 60) where |
188 subst_Bool :: "'a assn \<Rightarrow> bool \<Rightarrow> 'a assn" ("_\<leftarrow>=_" [60,61] 60) |
|
189 "P\<leftarrow>=b \<equiv> \<lambda>Y s Z. \<exists>v. P (Val v) s Z \<and> (normal s \<longrightarrow> the_Bool v=b)" |
183 "P\<leftarrow>=b \<equiv> \<lambda>Y s Z. \<exists>v. P (Val v) s Z \<and> (normal s \<longrightarrow> the_Bool v=b)" |
190 |
184 |
191 lemma subst_Bool_def2 [simp]: |
185 lemma subst_Bool_def2 [simp]: |
192 "(P\<leftarrow>=b) Y s Z = (\<exists>v. P (Val v) s Z \<and> (normal s \<longrightarrow> the_Bool v=b))" |
186 "(P\<leftarrow>=b) Y s Z = (\<exists>v. P (Val v) s Z \<and> (normal s \<longrightarrow> the_Bool v=b))" |
193 apply (unfold subst_Bool_def) |
187 apply (unfold subst_Bool_def) |
198 apply auto |
192 apply auto |
199 done |
193 done |
200 |
194 |
201 subsection "peek-res" |
195 subsection "peek-res" |
202 |
196 |
203 constdefs |
197 definition peek_res :: "(res \<Rightarrow> 'a assn) \<Rightarrow> 'a assn" where |
204 peek_res :: "(res \<Rightarrow> 'a assn) \<Rightarrow> 'a assn" |
|
205 "peek_res Pf \<equiv> \<lambda>Y. Pf Y Y" |
198 "peek_res Pf \<equiv> \<lambda>Y. Pf Y Y" |
206 |
199 |
207 syntax |
200 syntax |
208 "_peek_res" :: "pttrn \<Rightarrow> 'a assn \<Rightarrow> 'a assn" ("\<lambda>_:. _" [0,3] 3) |
201 "_peek_res" :: "pttrn \<Rightarrow> 'a assn \<Rightarrow> 'a assn" ("\<lambda>_:. _" [0,3] 3) |
209 translations |
202 translations |
227 apply fast |
220 apply fast |
228 done |
221 done |
229 |
222 |
230 subsection "ign-res" |
223 subsection "ign-res" |
231 |
224 |
232 constdefs |
225 definition ign_res :: " 'a assn \<Rightarrow> 'a assn" ("_\<down>" [1000] 1000) where |
233 ign_res :: " 'a assn \<Rightarrow> 'a assn" ("_\<down>" [1000] 1000) |
|
234 "P\<down> \<equiv> \<lambda>Y s Z. \<exists>Y. P Y s Z" |
226 "P\<down> \<equiv> \<lambda>Y s Z. \<exists>Y. P Y s Z" |
235 |
227 |
236 lemma ign_res_def2 [simp]: "P\<down> Y s Z = (\<exists>Y. P Y s Z)" |
228 lemma ign_res_def2 [simp]: "P\<down> Y s Z = (\<exists>Y. P Y s Z)" |
237 apply (unfold ign_res_def) |
229 apply (unfold ign_res_def) |
238 apply (simp (no_asm)) |
230 apply (simp (no_asm)) |
259 apply (simp (no_asm)) |
251 apply (simp (no_asm)) |
260 done |
252 done |
261 |
253 |
262 subsection "peek-st" |
254 subsection "peek-st" |
263 |
255 |
264 constdefs |
256 definition peek_st :: "(st \<Rightarrow> 'a assn) \<Rightarrow> 'a assn" where |
265 peek_st :: "(st \<Rightarrow> 'a assn) \<Rightarrow> 'a assn" |
|
266 "peek_st P \<equiv> \<lambda>Y s. P (store s) Y s" |
257 "peek_st P \<equiv> \<lambda>Y s. P (store s) Y s" |
267 |
258 |
268 syntax |
259 syntax |
269 "_peek_st" :: "pttrn \<Rightarrow> 'a assn \<Rightarrow> 'a assn" ("\<lambda>_.. _" [0,3] 3) |
260 "_peek_st" :: "pttrn \<Rightarrow> 'a assn \<Rightarrow> 'a assn" ("\<lambda>_.. _" [0,3] 3) |
270 translations |
261 translations |
304 apply (simp (no_asm)) |
295 apply (simp (no_asm)) |
305 done |
296 done |
306 |
297 |
307 subsection "ign-res-eq" |
298 subsection "ign-res-eq" |
308 |
299 |
309 constdefs |
300 definition ign_res_eq :: "'a assn \<Rightarrow> res \<Rightarrow> 'a assn" ("_\<down>=_" [60,61] 60) where |
310 ign_res_eq :: "'a assn \<Rightarrow> res \<Rightarrow> 'a assn" ("_\<down>=_" [60,61] 60) |
|
311 "P\<down>=w \<equiv> \<lambda>Y:. P\<down> \<and>. (\<lambda>s. Y=w)" |
301 "P\<down>=w \<equiv> \<lambda>Y:. P\<down> \<and>. (\<lambda>s. Y=w)" |
312 |
302 |
313 lemma ign_res_eq_def2 [simp]: "(P\<down>=w) Y s Z = ((\<exists>Y. P Y s Z) \<and> Y=w)" |
303 lemma ign_res_eq_def2 [simp]: "(P\<down>=w) Y s Z = ((\<exists>Y. P Y s Z) \<and> Y=w)" |
314 apply (unfold ign_res_eq_def) |
304 apply (unfold ign_res_eq_def) |
315 apply auto |
305 apply auto |
335 apply (simp (no_asm)) |
325 apply (simp (no_asm)) |
336 done |
326 done |
337 |
327 |
338 subsection "RefVar" |
328 subsection "RefVar" |
339 |
329 |
340 constdefs |
330 definition RefVar :: "(state \<Rightarrow> vvar \<times> state) \<Rightarrow> 'a assn \<Rightarrow> 'a assn" (infixr "..;" 13) where |
341 RefVar :: "(state \<Rightarrow> vvar \<times> state) \<Rightarrow> 'a assn \<Rightarrow> 'a assn"(infixr "..;" 13) |
|
342 "vf ..; P \<equiv> \<lambda>Y s. let (v,s') = vf s in P (Var v) s'" |
331 "vf ..; P \<equiv> \<lambda>Y s. let (v,s') = vf s in P (Var v) s'" |
343 |
332 |
344 lemma RefVar_def2 [simp]: "(vf ..; P) Y s = |
333 lemma RefVar_def2 [simp]: "(vf ..; P) Y s = |
345 P (Var (fst (vf s))) (snd (vf s))" |
334 P (Var (fst (vf s))) (snd (vf s))" |
346 apply (unfold RefVar_def Let_def) |
335 apply (unfold RefVar_def Let_def) |
347 apply (simp (no_asm) add: split_beta) |
336 apply (simp (no_asm) add: split_beta) |
348 done |
337 done |
349 |
338 |
350 subsection "allocation" |
339 subsection "allocation" |
351 |
340 |
352 constdefs |
341 definition Alloc :: "prog \<Rightarrow> obj_tag \<Rightarrow> 'a assn \<Rightarrow> 'a assn" where |
353 Alloc :: "prog \<Rightarrow> obj_tag \<Rightarrow> 'a assn \<Rightarrow> 'a assn" |
|
354 "Alloc G otag P \<equiv> \<lambda>Y s Z. |
342 "Alloc G otag P \<equiv> \<lambda>Y s Z. |
355 \<forall>s' a. G\<turnstile>s \<midarrow>halloc otag\<succ>a\<rightarrow> s'\<longrightarrow> P (Val (Addr a)) s' Z" |
343 \<forall>s' a. G\<turnstile>s \<midarrow>halloc otag\<succ>a\<rightarrow> s'\<longrightarrow> P (Val (Addr a)) s' Z" |
356 |
344 |
357 SXAlloc :: "prog \<Rightarrow> 'a assn \<Rightarrow> 'a assn" |
345 definition SXAlloc :: "prog \<Rightarrow> 'a assn \<Rightarrow> 'a assn" where |
358 "SXAlloc G P \<equiv> \<lambda>Y s Z. \<forall>s'. G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s' \<longrightarrow> P Y s' Z" |
346 "SXAlloc G P \<equiv> \<lambda>Y s Z. \<forall>s'. G\<turnstile>s \<midarrow>sxalloc\<rightarrow> s' \<longrightarrow> P Y s' Z" |
359 |
347 |
360 |
348 |
361 lemma Alloc_def2 [simp]: "Alloc G otag P Y s Z = |
349 lemma Alloc_def2 [simp]: "Alloc G otag P Y s Z = |
362 (\<forall>s' a. G\<turnstile>s \<midarrow>halloc otag\<succ>a\<rightarrow> s'\<longrightarrow> P (Val (Addr a)) s' Z)" |
350 (\<forall>s' a. G\<turnstile>s \<midarrow>halloc otag\<succ>a\<rightarrow> s'\<longrightarrow> P (Val (Addr a)) s' Z)" |
370 apply (simp (no_asm)) |
358 apply (simp (no_asm)) |
371 done |
359 done |
372 |
360 |
373 section "validity" |
361 section "validity" |
374 |
362 |
375 constdefs |
363 definition type_ok :: "prog \<Rightarrow> term \<Rightarrow> state \<Rightarrow> bool" where |
376 type_ok :: "prog \<Rightarrow> term \<Rightarrow> state \<Rightarrow> bool" |
|
377 "type_ok G t s \<equiv> |
364 "type_ok G t s \<equiv> |
378 \<exists>L T C A. (normal s \<longrightarrow> \<lparr>prg=G,cls=C,lcl=L\<rparr>\<turnstile>t\<Colon>T \<and> |
365 \<exists>L T C A. (normal s \<longrightarrow> \<lparr>prg=G,cls=C,lcl=L\<rparr>\<turnstile>t\<Colon>T \<and> |
379 \<lparr>prg=G,cls=C,lcl=L\<rparr>\<turnstile>dom (locals (store s))\<guillemotright>t\<guillemotright>A ) |
366 \<lparr>prg=G,cls=C,lcl=L\<rparr>\<turnstile>dom (locals (store s))\<guillemotright>t\<guillemotright>A ) |
380 \<and> s\<Colon>\<preceq>(G,L)" |
367 \<and> s\<Colon>\<preceq>(G,L)" |
381 |
368 |
417 |
404 |
418 lemma triple_inj_eq: "({P} t\<succ> {Q} = {P'} t'\<succ> {Q'} ) = (P=P' \<and> t=t' \<and> Q=Q')" |
405 lemma triple_inj_eq: "({P} t\<succ> {Q} = {P'} t'\<succ> {Q'} ) = (P=P' \<and> t=t' \<and> Q=Q')" |
419 apply auto |
406 apply auto |
420 done |
407 done |
421 |
408 |
422 constdefs |
409 definition mtriples :: "('c \<Rightarrow> 'sig \<Rightarrow> 'a assn) \<Rightarrow> ('c \<Rightarrow> 'sig \<Rightarrow> expr) \<Rightarrow> |
423 mtriples :: "('c \<Rightarrow> 'sig \<Rightarrow> 'a assn) \<Rightarrow> ('c \<Rightarrow> 'sig \<Rightarrow> expr) \<Rightarrow> |
410 ('c \<Rightarrow> 'sig \<Rightarrow> 'a assn) \<Rightarrow> ('c \<times> 'sig) set \<Rightarrow> 'a triples" ("{{(1_)}/ _-\<succ>/ {(1_)} | _}"[3,65,3,65]75) where |
424 ('c \<Rightarrow> 'sig \<Rightarrow> 'a assn) \<Rightarrow> ('c \<times> 'sig) set \<Rightarrow> 'a triples" |
|
425 ("{{(1_)}/ _-\<succ>/ {(1_)} | _}"[3,65,3,65]75) |
|
426 "{{P} tf-\<succ> {Q} | ms} \<equiv> (\<lambda>(C,sig). {Normal(P C sig)} tf C sig-\<succ> {Q C sig})`ms" |
411 "{{P} tf-\<succ> {Q} | ms} \<equiv> (\<lambda>(C,sig). {Normal(P C sig)} tf C sig-\<succ> {Q C sig})`ms" |
427 |
412 |
428 consts |
413 consts |
429 |
414 |
430 triple_valid :: "prog \<Rightarrow> nat \<Rightarrow> 'a triple \<Rightarrow> bool" |
415 triple_valid :: "prog \<Rightarrow> nat \<Rightarrow> 'a triple \<Rightarrow> bool" |
639 | FinA: " G,A\<turnstile>{Normal P} .FinA a c. {Q}" |
624 | FinA: " G,A\<turnstile>{Normal P} .FinA a c. {Q}" |
640 (* |
625 (* |
641 axioms |
626 axioms |
642 *) |
627 *) |
643 |
628 |
644 constdefs |
629 definition adapt_pre :: "'a assn \<Rightarrow> 'a assn \<Rightarrow> 'a assn \<Rightarrow> 'a assn" where |
645 adapt_pre :: "'a assn \<Rightarrow> 'a assn \<Rightarrow> 'a assn \<Rightarrow> 'a assn" |
|
646 "adapt_pre P Q Q'\<equiv>\<lambda>Y s Z. \<forall>Y' s'. \<exists>Z'. P Y s Z' \<and> (Q Y' s' Z' \<longrightarrow> Q' Y' s' Z)" |
630 "adapt_pre P Q Q'\<equiv>\<lambda>Y s Z. \<forall>Y' s'. \<exists>Z'. P Y s Z' \<and> (Q Y' s' Z' \<longrightarrow> Q' Y' s' Z)" |
647 |
631 |
648 |
632 |
649 section "rules derived by induction" |
633 section "rules derived by induction" |
650 |
634 |