1 (* Title: HOL/Bali/Name.thy
3 Author: David von Oheimb
4 License: GPL (GNU GENERAL PUBLIC LICENSE)
6 header {* Java names *}
11 typedecl tnam (* ordinary type name, i.e. class or interface name *)
12 typedecl pname (* package name *)
13 typedecl mname (* method name *)
14 typedecl vname (* variable or field name *)
15 typedecl label (* label as destination of break or continue *)
25 datatype ename (* expression name *)
27 | Res (* special name to model the return value of methods *)
29 datatype lname (* names for local variables and the This pointer *)
33 VName :: "vname \<Rightarrow> lname"
37 "VName n" == "EName (VNam n)"
38 "Result" == "EName Res"
40 datatype xname (* names of standard exceptions *)
42 | NullPointer | OutOfMemory | ClassCast
43 | NegArrSize | IndOutBound | ArrStore
46 "xn = Throwable \<or> xn = NullPointer \<or>
47 xn = OutOfMemory \<or> xn = ClassCast \<or>
48 xn = NegArrSize \<or> xn = IndOutBound \<or> xn = ArrStore"
53 lemma xn_cases_old: (* FIXME cf. Example.thy *)
54 "ALL xn. xn = Throwable \<or> xn = NullPointer \<or>
55 xn = OutOfMemory \<or> xn = ClassCast \<or>
56 xn = NegArrSize \<or> xn = IndOutBound \<or> xn = ArrStore"
62 datatype tname (* type names for standard classes and other type names *)
67 record qtname = (* qualified tname cf. 6.5.3, 6.5.4*)
71 axclass has_pname < "type"
72 consts pname::"'a::has_pname \<Rightarrow> pname"
74 instance pname::has_pname ..
77 pname_pname_def: "pname (p::pname) \<equiv> p"
79 axclass has_tname < "type"
80 consts tname::"'a::has_tname \<Rightarrow> tname"
82 instance tname::has_tname ..
85 tname_tname_def: "tname (t::tname) \<equiv> t"
87 axclass has_qtname < "type"
88 consts qtname:: "'a::has_qtname \<Rightarrow> qtname"
90 (* Declare qtname as instance of has_qtname *)
91 instance pid_field_type::(has_pname,"type") has_qtname ..
94 qtname_qtname_def: "qtname (q::qtname) \<equiv> q"
97 "mname" <= "Name.mname"
98 "xname" <= "Name.xname"
99 "tname" <= "Name.tname"
100 "ename" <= "Name.ename"
101 "qtname" <= (type) "\<lparr>pid::pname,tid::tname\<rparr>"
102 (type) "'a qtname_scheme" <= (type) "\<lparr>pid::pname,tid::tname,\<dots>::'a\<rparr>"
105 consts java_lang::pname (* package java.lang *)
109 SXcpt :: "xname \<Rightarrow> qtname"
111 Object_def: "Object \<equiv> \<lparr>pid = java_lang, tid = Object_\<rparr>"
112 SXcpt_def: "SXcpt \<equiv> \<lambda>x. \<lparr>pid = java_lang, tid = SXcpt_ x\<rparr>"
114 lemma Object_neq_SXcpt [simp]: "Object \<noteq> SXcpt xn"
115 by (simp add: Object_def SXcpt_def)
117 lemma SXcpt_inject [simp]: "(SXcpt xn = SXcpt xm) = (xn = xm)"
118 by (simp add: SXcpt_def)