src/HOL/MicroJava/J/Conform.thy
changeset 13672 b95d12325b51
parent 12951 a9fdcb71d252
child 14134 0fdf5708c7a8
equal deleted inserted replaced
13671:eec2582923f6 13672:b95d12325b51
     4     Copyright   1999 Technische Universitaet Muenchen
     4     Copyright   1999 Technische Universitaet Muenchen
     5 *)
     5 *)
     6 
     6 
     7 header {* \isaheader{Conformity Relations for Type Soundness Proof} *}
     7 header {* \isaheader{Conformity Relations for Type Soundness Proof} *}
     8 
     8 
     9 theory Conform = State + WellType:
     9 theory Conform = State + WellType + Exceptions:
    10 
    10 
    11 types 'c env_ = "'c prog \<times> (vname \<leadsto> ty)"  -- "same as @{text env} of @{text WellType.thy}"
    11 types 'c env_ = "'c prog \<times> (vname \<leadsto> ty)"  -- "same as @{text env} of @{text WellType.thy}"
    12 
    12 
    13 constdefs
    13 constdefs
    14 
    14 
    26   oconf :: "'c prog => aheap => obj => bool" ("_,_ |- _ [ok]" [51,51,51] 50)
    26   oconf :: "'c prog => aheap => obj => bool" ("_,_ |- _ [ok]" [51,51,51] 50)
    27  "G,h|-obj [ok] == G,h|-snd obj[::<=]map_of (fields (G,fst obj))"
    27  "G,h|-obj [ok] == G,h|-snd obj[::<=]map_of (fields (G,fst obj))"
    28 
    28 
    29   hconf :: "'c prog => aheap => bool" ("_ |-h _ [ok]" [51,51] 50)
    29   hconf :: "'c prog => aheap => bool" ("_ |-h _ [ok]" [51,51] 50)
    30  "G|-h h [ok]    == \<forall>a obj. h a = Some obj --> G,h|-obj [ok]"
    30  "G|-h h [ok]    == \<forall>a obj. h a = Some obj --> G,h|-obj [ok]"
    31 
    31  
    32   conforms :: "state => java_mb env_ => bool" ("_ ::<= _" [51,51] 50)
    32   xconf :: "aheap \<Rightarrow> val option \<Rightarrow> bool"
    33  "s::<=E == prg E|-h heap s [ok] \<and> prg E,heap s|-locals s[::<=]localT E"
    33   "xconf hp vo  == preallocated hp \<and> (\<forall> v. (vo = Some v) \<longrightarrow> (\<exists> xc. v = (Addr (XcptRef xc))))"
       
    34 
       
    35   conforms :: "xstate => java_mb env_ => bool" ("_ ::<= _" [51,51] 50)
       
    36  "s::<=E == prg E|-h heap (store s) [ok] \<and> 
       
    37             prg E,heap (store s)|-locals (store s)[::<=]localT E \<and> 
       
    38             xconf (heap (store s)) (abrupt s)"
    34 
    39 
    35 
    40 
    36 syntax (xsymbols)
    41 syntax (xsymbols)
    37   hext     :: "aheap => aheap => bool"
    42   hext     :: "aheap => aheap => bool"
    38               ("_ \<le>| _" [51,51] 50)
    43               ("_ \<le>| _" [51,51] 50)
   245 apply( clarsimp)
   250 apply( clarsimp)
   246 apply( frule list_all2_lengthD)
   251 apply( frule list_all2_lengthD)
   247 apply( auto simp add: length_Suc_conv)
   252 apply( auto simp add: length_Suc_conv)
   248 done
   253 done
   249 
   254 
       
   255 lemma lconf_restr: "\<lbrakk>lT vn = None; G, h \<turnstile> l [::\<preceq>] lT(vn\<mapsto>T)\<rbrakk> \<Longrightarrow> G, h \<turnstile> l [::\<preceq>] lT"
       
   256 apply (unfold lconf_def)
       
   257 apply (intro strip)
       
   258 apply (case_tac "n = vn")
       
   259 apply auto
       
   260 done
   250 
   261 
   251 section "oconf"
   262 section "oconf"
   252 
   263 
   253 lemma oconf_hext: "G,h\<turnstile>obj\<surd> ==> h\<le>|h' ==> G,h'\<turnstile>obj\<surd>"
   264 lemma oconf_hext: "G,h\<turnstile>obj\<surd> ==> h\<le>|h' ==> G,h'\<turnstile>obj\<surd>"
   254 apply (unfold oconf_def)
   265 apply (unfold oconf_def)
   275 apply (unfold hconf_def)
   286 apply (unfold hconf_def)
   276 apply (fast)
   287 apply (fast)
   277 done
   288 done
   278 
   289 
   279 
   290 
       
   291 section "xconf"
       
   292 
       
   293 lemma xconf_raise_if: "xconf h x \<Longrightarrow> xconf h (raise_if b xcn x)"
       
   294 by (simp add: xconf_def raise_if_def)
       
   295 
       
   296 
       
   297 
   280 section "conforms"
   298 section "conforms"
   281 
   299 
   282 lemma conforms_heapD: "(h, l)::\<preceq>(G, lT) ==> G\<turnstile>h h\<surd>"
   300 lemma conforms_heapD: "(x, (h, l))::\<preceq>(G, lT) ==> G\<turnstile>h h\<surd>"
   283 apply (unfold conforms_def)
   301 apply (unfold conforms_def)
   284 apply (simp)
   302 apply (simp)
   285 done
   303 done
   286 
   304 
   287 lemma conforms_localD: "(h, l)::\<preceq>(G, lT) ==> G,h\<turnstile>l[::\<preceq>]lT"
   305 lemma conforms_localD: "(x, (h, l))::\<preceq>(G, lT) ==> G,h\<turnstile>l[::\<preceq>]lT"
   288 apply (unfold conforms_def)
   306 apply (unfold conforms_def)
   289 apply (simp)
   307 apply (simp)
   290 done
   308 done
   291 
   309 
   292 lemma conformsI: "[|G\<turnstile>h h\<surd>; G,h\<turnstile>l[::\<preceq>]lT|] ==> (h, l)::\<preceq>(G, lT)"
   310 lemma conforms_xcptD: "(x, (h, l))::\<preceq>(G, lT) ==> xconf h x"
   293 apply (unfold conforms_def)
   311 apply (unfold conforms_def)
   294 apply auto
   312 apply (simp)
   295 done
   313 done
   296 
   314 
   297 lemma conforms_hext: "[|(h,l)::\<preceq>(G,lT); h\<le>|h'; G\<turnstile>h h'\<surd> |] ==> (h',l)::\<preceq>(G,lT)"
   315 lemma conformsI: "[|G\<turnstile>h h\<surd>; G,h\<turnstile>l[::\<preceq>]lT; xconf h x|] ==> (x, (h, l))::\<preceq>(G, lT)"
   298 apply( fast dest: conforms_localD elim!: conformsI lconf_hext)
   316 apply (unfold conforms_def)
   299 done
   317 apply auto
       
   318 done
       
   319 
       
   320 lemma conforms_restr: "\<lbrakk>lT vn = None; s ::\<preceq> (G, lT(vn\<mapsto>T)) \<rbrakk> \<Longrightarrow> s ::\<preceq> (G, lT)"
       
   321 by (simp add: conforms_def, fast intro: lconf_restr)
       
   322 
       
   323 lemma conforms_xcpt_change: "\<lbrakk> (x, (h,l))::\<preceq> (G, lT); xconf h x \<longrightarrow> xconf h x' \<rbrakk> \<Longrightarrow> (x', (h,l))::\<preceq> (G, lT)"
       
   324 by (simp add: conforms_def)
       
   325 
       
   326 
       
   327 lemma preallocated_hext: "\<lbrakk> preallocated h; h\<le>|h'\<rbrakk> \<Longrightarrow> preallocated h'"
       
   328 by (simp add: preallocated_def hext_def)
       
   329 
       
   330 lemma xconf_hext: "\<lbrakk> xconf h vo; h\<le>|h'\<rbrakk> \<Longrightarrow> xconf h' vo"
       
   331 by (simp add: xconf_def preallocated_def hext_def)
       
   332 
       
   333 lemma conforms_hext: "[|(x,(h,l))::\<preceq>(G,lT); h\<le>|h'; G\<turnstile>h h'\<surd> |] 
       
   334   ==> (x,(h',l))::\<preceq>(G,lT)"
       
   335 by( fast dest: conforms_localD conforms_xcptD elim!: conformsI xconf_hext)
       
   336 
   300 
   337 
   301 lemma conforms_upd_obj: 
   338 lemma conforms_upd_obj: 
   302   "[|(h,l)::\<preceq>(G, lT); G,h(a\<mapsto>obj)\<turnstile>obj\<surd>; h\<le>|h(a\<mapsto>obj)|] ==> (h(a\<mapsto>obj),l)::\<preceq>(G, lT)"
   339   "[|(x,(h,l))::\<preceq>(G, lT); G,h(a\<mapsto>obj)\<turnstile>obj\<surd>; h\<le>|h(a\<mapsto>obj)|] 
       
   340   ==> (x,(h(a\<mapsto>obj),l))::\<preceq>(G, lT)"
   303 apply(rule conforms_hext)
   341 apply(rule conforms_hext)
   304 apply  auto
   342 apply  auto
   305 apply(rule hconfI)
   343 apply(rule hconfI)
   306 apply(drule conforms_heapD)
   344 apply(drule conforms_heapD)
   307 apply(tactic {* auto_tac (HOL_cs addEs [thm "oconf_hext"] 
   345 apply(tactic {* auto_tac (HOL_cs addEs [thm "oconf_hext"] 
   308                 addDs [thm "hconfD"], simpset() delsimps [split_paired_All]) *})
   346                 addDs [thm "hconfD"], simpset() delsimps [split_paired_All]) *})
   309 done
   347 done
   310 
   348 
   311 lemma conforms_upd_local: 
   349 lemma conforms_upd_local: 
   312 "[|(h, l)::\<preceq>(G, lT); G,h\<turnstile>v::\<preceq>T; lT va = Some T|] ==> (h, l(va\<mapsto>v))::\<preceq>(G, lT)"
   350 "[|(x,(h, l))::\<preceq>(G, lT); G,h\<turnstile>v::\<preceq>T; lT va = Some T|] 
       
   351   ==> (x,(h, l(va\<mapsto>v)))::\<preceq>(G, lT)"
   313 apply (unfold conforms_def)
   352 apply (unfold conforms_def)
   314 apply( auto elim: lconf_upd)
   353 apply( auto elim: lconf_upd)
   315 done
   354 done
   316 
   355 
   317 end
   356 end