src/HOL/Bali/Name.thy
author haftmann
Fri Jun 17 16:12:49 2005 +0200 (2005-06-17)
changeset 16417 9bc16273c2d4
parent 14981 e73f8140af78
child 17160 fb65eda72fc7
permissions -rw-r--r--
migrated theory headers to new format
wenzelm@12857
     1
(*  Title:      HOL/Bali/Name.thy
schirmer@12854
     2
    ID:         $Id$
schirmer@12854
     3
    Author:     David von Oheimb
schirmer@12854
     4
*)
schirmer@12854
     5
header {* Java names *}
schirmer@12854
     6
haftmann@16417
     7
theory Name imports Basis begin
schirmer@12854
     8
schirmer@12854
     9
(* cf. 6.5 *) 
schirmer@13688
    10
typedecl tnam	--{* ordinary type name, i.e. class or interface name *}
schirmer@13688
    11
typedecl pname  --{* package name *}
schirmer@13688
    12
typedecl mname  --{* method name *}
schirmer@13688
    13
typedecl vname  --{* variable or field name *}
schirmer@13688
    14
typedecl label  --{* label as destination of break or continue *}
schirmer@12854
    15
schirmer@12854
    16
arities
schirmer@12854
    17
  tnam  :: "type"
schirmer@12854
    18
  pname :: "type"
schirmer@12854
    19
  vname :: "type"
schirmer@12854
    20
  mname :: "type"
schirmer@12854
    21
  label :: "type"
schirmer@12854
    22
schirmer@12854
    23
schirmer@13688
    24
datatype ename        --{* expression name *} 
schirmer@12854
    25
        = VNam vname 
schirmer@13688
    26
        | Res         --{* special name to model the return value of methods *}
schirmer@12854
    27
schirmer@13688
    28
datatype lname        --{* names for local variables and the This pointer *}
schirmer@12854
    29
        = EName ename 
schirmer@12854
    30
        | This
schirmer@12854
    31
syntax   
schirmer@12854
    32
  VName  :: "vname \<Rightarrow> lname"
schirmer@12854
    33
  Result :: lname
schirmer@12854
    34
schirmer@12854
    35
translations
schirmer@12854
    36
  "VName n" == "EName (VNam n)"
schirmer@12854
    37
  "Result"  == "EName Res"
schirmer@12854
    38
schirmer@13688
    39
datatype xname		--{* names of standard exceptions *}
schirmer@12854
    40
	= Throwable
schirmer@12854
    41
	| NullPointer | OutOfMemory | ClassCast   
schirmer@12854
    42
	| NegArrSize  | IndOutBound | ArrStore
schirmer@12854
    43
schirmer@12854
    44
lemma xn_cases: 
schirmer@12854
    45
  "xn = Throwable   \<or> xn = NullPointer \<or>  
schirmer@12854
    46
         xn = OutOfMemory \<or> xn = ClassCast \<or> 
schirmer@12854
    47
         xn = NegArrSize  \<or> xn = IndOutBound \<or> xn = ArrStore"
schirmer@12854
    48
apply (induct xn)
schirmer@12854
    49
apply auto
schirmer@12854
    50
done
schirmer@12854
    51
schirmer@12854
    52
schirmer@13688
    53
datatype tname	--{* type names for standard classes and other type names *}
schirmer@12854
    54
	= Object_
schirmer@12854
    55
	| SXcpt_   xname
schirmer@12854
    56
	| TName   tnam
schirmer@12854
    57
schirmer@13688
    58
record   qtname = --{* qualified tname cf. 6.5.3, 6.5.4*}
schirmer@13688
    59
          pid :: pname  
schirmer@12854
    60
          tid :: tname
schirmer@12854
    61
schirmer@12854
    62
axclass has_pname < "type"
schirmer@12854
    63
consts pname::"'a::has_pname \<Rightarrow> pname"
schirmer@12854
    64
wenzelm@12859
    65
instance pname::has_pname ..
schirmer@12854
    66
schirmer@12854
    67
defs (overloaded)
schirmer@12854
    68
pname_pname_def: "pname (p::pname) \<equiv> p"
schirmer@12854
    69
schirmer@12854
    70
axclass has_tname < "type"
schirmer@12854
    71
consts tname::"'a::has_tname \<Rightarrow> tname"
schirmer@12854
    72
wenzelm@12859
    73
instance tname::has_tname ..
schirmer@12854
    74
schirmer@12854
    75
defs (overloaded)
schirmer@12854
    76
tname_tname_def: "tname (t::tname) \<equiv> t"
schirmer@12854
    77
schirmer@12854
    78
axclass has_qtname < "type"
schirmer@12854
    79
consts qtname:: "'a::has_qtname \<Rightarrow> qtname"
schirmer@12854
    80
schirmer@12854
    81
(* Declare qtname as instance of has_qtname *)
schirmer@14700
    82
instance qtname_ext_type::("type") has_qtname ..
schirmer@12854
    83
schirmer@12854
    84
defs (overloaded)
schirmer@12854
    85
qtname_qtname_def: "qtname (q::qtname) \<equiv> q"
schirmer@12854
    86
schirmer@12854
    87
translations
schirmer@12854
    88
  "mname"  <= "Name.mname"
schirmer@12854
    89
  "xname"  <= "Name.xname"
schirmer@12854
    90
  "tname"  <= "Name.tname"
schirmer@12854
    91
  "ename"  <= "Name.ename"
schirmer@12854
    92
  "qtname" <= (type) "\<lparr>pid::pname,tid::tname\<rparr>"
schirmer@12854
    93
  (type) "'a qtname_scheme" <= (type) "\<lparr>pid::pname,tid::tname,\<dots>::'a\<rparr>"
schirmer@12854
    94
schirmer@12854
    95
schirmer@13688
    96
consts java_lang::pname --{* package java.lang *}
schirmer@12854
    97
schirmer@12854
    98
consts 
schirmer@12854
    99
  Object :: qtname
schirmer@12854
   100
  SXcpt  :: "xname \<Rightarrow> qtname"
schirmer@12854
   101
defs
schirmer@12854
   102
  Object_def: "Object  \<equiv> \<lparr>pid = java_lang, tid = Object_\<rparr>"
schirmer@12854
   103
  SXcpt_def:  "SXcpt   \<equiv> \<lambda>x.  \<lparr>pid = java_lang, tid = SXcpt_ x\<rparr>"
schirmer@12854
   104
schirmer@12854
   105
lemma Object_neq_SXcpt [simp]: "Object \<noteq> SXcpt xn"
schirmer@12854
   106
by (simp add: Object_def SXcpt_def)
schirmer@12854
   107
schirmer@12854
   108
lemma SXcpt_inject [simp]: "(SXcpt xn = SXcpt xm) = (xn = xm)"
schirmer@12854
   109
by (simp add: SXcpt_def)
schirmer@12854
   110
end
schirmer@12854
   111