(* Title: HOL/MicroJava/J/Conform.thy Author: David von Oheimb Copyright 1999 Technische Universitaet Muenchen
*)
section \<open>Conformity Relations for Type Soundness Proof\<close>
theory Conform imports State WellType Exceptions begin
type_synonym'c env' = "'c prog \ (vname \ ty)" \ \same as \env\ of \WellType.thy\\
definition(* Title: HOL/MicroJava/J/Conform.thy "h\<le>|h' == \<forall>a C fs. h a = Some(C,fs) --> (\<exists>fs'. h' a = Some(C,fs'))"
definition conf :: "'c prog => aheap => val => ty => bool" (\<open>_,_ \<turnstile> _ ::\<preceq> _\<close> [51,51,51,51] 50) where "G,h\<turnstile>v::\<preceq>T == \<exists>T'. typeof (map_option obj_ty o h) v = Some T' \<and> G\<turnstile>T'\<preceq>T"
definition lconf :: "'c prog => aheap => ('a \<rightharpoonup> val) => ('a \<rightharpoonup> ty) => bool" (\<open>_,_ \<turnstile> _ [::\<preceq>] _\<close> [51,51,51,51] 50) where "G,h\<turnstile>vs[::\<preceq>]Ts == \<forall>n T. Ts n = Some T --> (\<exists>v. vs n = Some v \<and> G,h\<turnstile>v::\<preceq>T)"
definition hconf :: "'c prog => aheap => bool" (\<open>_ \<turnstile>h _ \<surd>\<close> [51,51] 50) where "G\<turnstile>h h \<surd> == \<forall>a obj. h a = Some obj --> G,h\<turnstile>obj \<surd>" definition xconf :: "aheap \<Rightarrow> val option \<Rightarrow> bool" where "xconf hp vo == preallocated hp \<and> (\<forall> v. (vo = Some v) \<longrightarrow> (\<exists> xc. v = (Addr (XcptRef xc))))"
lemma new_locD: "[|h a = None; G,h\<turnstile>Addr t::\<preceq>T|] ==> t\<noteq>a" apply (unfold conf_def) apply auto done
lemma conf_RefTD [rule_format]: "G,h\<turnstile>a'::\<preceq>RefT T \<Longrightarrow> a' = Null \<or> (\<exists>a obj T'. a' = Addr a \<and> h a = Some obj \<and> obj_ty obj = T' \<and> G\<turnstile>T'\<preceq>RefT T)" unfolding conf_def by (induct a') auto
lemma conf_NullTD: "G,h\<turnstile>a'::\<preceq>RefT NullT ==> a' = Null" apply (drule conf_RefTD) apply auto done
lemma non_npD: "[|a' \<noteq> Null; G,h\<turnstile>a'::\<preceq>RefT t|] ==> \<exists>a C fs. a' = Addr a \<and> h a = Some (C,fs) \<and> G\<turnstile>Class C\<preceq>RefT t" apply (drule conf_RefTD) apply auto done
lemma non_np_objD: "!!G. [|a' \<noteq> Null; G,h\<turnstile>a'::\<preceq> Class C|] ==> (\<exists>a C' fs. a' = Addr a \<and> h a = Some (C',fs) \<and> G\<turnstile>C'\<preceq>C C)" apply (fast dest: non_npD) done
lemma non_np_objD' [rule_format (no_asm)]: "a' \<noteq> Null ==> wf_prog wf_mb G ==> G,h\<turnstile>a'::\<preceq>RefT t --> (\<exists>a C fs. a' = Addr a \<and> h a = Some (C,fs) \<and> G\<turnstile>Class C\<preceq>RefT t)" apply(rule_tac y = "t" in ref_ty.exhaust) apply (fast dest: conf_NullTD) apply (fast dest: non_np_objD) done
lemma lconf_upd: "!!X. [| G,h\<turnstile>l[::\<preceq>]lT; G,h\<turnstile>v::\<preceq>T; lT va = Some T |] ==> G,h\<turnstile>l(va\<mapsto>v)[::\<preceq>]lT" apply (unfold lconf_def) apply auto done
lemma lconf_init_vars_lemma [rule_format (no_asm)]: "\<forall>x. P x --> R (dv x) x ==> (\<forall>x. map_of fs f = Some x --> P x) --> (\<forall>T. map_of fs f = Some T --> (\<exists>v. map_of (map (\<lambda>(f,ft). (f, dv ft)) fs) f = Some v \<and> R v T))" apply( induct_tac "fs") apply auto done
lemma lconf_init_vars [intro!]: "\<forall>n. \<forall>T. map_of fs n = Some T --> is_type G T ==> G,h\<turnstile>init_vars fs[::\<preceq>]map_of fs" apply (unfold lconf_def init_vars_def) apply auto apply( rule lconf_init_vars_lemma) apply( erule_tac [3] asm_rl) apply( intro strip) apply( erule defval_conf) apply auto done
lemma oconf_obj: "G,h\<turnstile>(C,fs)\<surd> = (\<forall>T f. map_of(fields (G,C)) f = Some T --> (\<exists>v. fs f = Some v \<and> G,h\<turnstile>v::\<preceq>T))" apply (unfold oconf_def lconf_def) apply auto done
lemmas oconf_objD = oconf_obj [THEN iffD1, THEN spec, THEN spec, THEN mp]
subsection "hconf"
lemma hconfD: "[|G\<turnstile>h h\<surd>; h a = Some obj|] ==> G,h\<turnstile>obj\<surd>" apply (unfold hconf_def) apply (fast) done
lemma conforms_upd_local: "[|(x,(h, l))::\<preceq>(G, lT); G,h\<turnstile>v::\<preceq>T; lT va = Some T|] ==> (x,(h, l(va\<mapsto>v)))::\<preceq>(G, lT)" apply (unfold conforms_def) apply( auto elim: lconf_upd) done
end
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.7Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.