src/HOL/Bali/DeclConcepts.thy
author schirmer
Mon, 28 Jan 2002 17:00:19 +0100
changeset 12854 00d4a435777f
child 12859 f63315dfffd4
permissions -rw-r--r--
Isabelle/Bali sources;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12854
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
     1
header {* Advanced concepts on Java declarations like overriding, inheritance,
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
     2
dynamic method lookup*}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
     3
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
     4
theory DeclConcepts = TypeRel:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
     5
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
     6
section "access control (cf. 6.6), overriding and hiding (cf. 8.4.6.1)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
     7
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
     8
constdefs
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
     9
is_public :: "prog \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    10
"is_public G qn \<equiv> (case class G qn of
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    11
                     None       \<Rightarrow> (case iface G qn of
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    12
                                      None       \<Rightarrow> False
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    13
                                    | Some iface \<Rightarrow> access iface = Public)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    14
                   | Some class \<Rightarrow> access class = Public)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    15
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    16
subsection "accessibility of types (cf. 6.6.1)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    17
text {* 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    18
Primitive types are always accessible, interfaces and classes are accessible
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    19
in their package or if they are defined public, an array type is accessible if
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    20
its element type is accessible *}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    21
 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    22
consts accessible_in   :: "prog \<Rightarrow> ty     \<Rightarrow> pname \<Rightarrow> bool"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    23
                                      ("_ \<turnstile> _ accessible'_in _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    24
       rt_accessible_in:: "prog \<Rightarrow> ref_ty \<Rightarrow> pname \<Rightarrow> bool" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    25
                                      ("_ \<turnstile> _ accessible'_in' _" [61,61,61] 60) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    26
primrec
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    27
"G\<turnstile>(PrimT p)   accessible_in pack  = True"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    28
accessible_in_RefT_simp: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    29
"G\<turnstile>(RefT  r)   accessible_in pack  = G\<turnstile>r accessible_in' pack"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    30
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    31
"G\<turnstile>(NullT)     accessible_in' pack = True"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    32
"G\<turnstile>(IfaceT I)  accessible_in' pack = ((pid I = pack) \<or> is_public G I)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    33
"G\<turnstile>(ClassT C)  accessible_in' pack = ((pid C = pack) \<or> is_public G C)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    34
"G\<turnstile>(ArrayT ty) accessible_in' pack = G\<turnstile>ty accessible_in pack"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    35
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    36
declare accessible_in_RefT_simp [simp del]
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    37
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    38
constdefs
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    39
  is_acc_class :: "prog \<Rightarrow> pname \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    40
    "is_acc_class G P C \<equiv> is_class G C \<and> G\<turnstile>(Class C) accessible_in P"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    41
  is_acc_iface :: "prog \<Rightarrow> pname \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    42
    "is_acc_iface G P I \<equiv> is_iface G I \<and> G\<turnstile>(Iface I) accessible_in P"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    43
  is_acc_type  :: "prog \<Rightarrow> pname \<Rightarrow> ty     \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    44
    "is_acc_type  G P T \<equiv> is_type G T  \<and> G\<turnstile>T accessible_in P"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    45
  is_acc_reftype  :: "prog \<Rightarrow> pname \<Rightarrow> ref_ty \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    46
  "is_acc_reftype  G P T \<equiv> isrtype G T  \<and> G\<turnstile>T accessible_in' P"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    47
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    48
lemma is_acc_classD:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    49
 "is_acc_class G P C \<Longrightarrow>  is_class G C \<and> G\<turnstile>(Class C) accessible_in P"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    50
by (simp add: is_acc_class_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    51
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    52
lemma is_acc_class_is_class: "is_acc_class G P C \<Longrightarrow> is_class G C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    53
by (auto simp add: is_acc_class_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    54
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    55
lemma is_acc_ifaceD:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    56
  "is_acc_iface G P I \<Longrightarrow> is_iface G I \<and> G\<turnstile>(Iface I) accessible_in P"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    57
by (simp add: is_acc_iface_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    58
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    59
lemma is_acc_typeD:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    60
 "is_acc_type  G P T \<equiv> is_type G T  \<and> G\<turnstile>T accessible_in P"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    61
by (simp add: is_acc_type_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    62
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    63
lemma is_acc_reftypeD:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    64
"is_acc_reftype  G P T \<Longrightarrow> isrtype G T  \<and> G\<turnstile>T accessible_in' P"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    65
by (simp add: is_acc_reftype_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    66
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    67
subsection "accessibility of members"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    68
text {*
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    69
The accessibility of members is more involved as the accessibility of types.
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    70
We have to distinguish several cases to model the different effects of 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    71
accessibility during inheritance, overriding and ordinary member access 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    72
*}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    73
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    74
subsubsection {* Various technical conversion and selection functions *}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    75
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    76
text {* overloaded selector @{text accmodi} to select the access modifier 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    77
out of various HOL types *}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    78
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    79
axclass has_accmodi < "type"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    80
consts accmodi:: "'a::has_accmodi \<Rightarrow> acc_modi"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    81
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    82
instance acc_modi::has_accmodi
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    83
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    84
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    85
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    86
acc_modi_accmodi_def: "accmodi (a::acc_modi) \<equiv> a"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    87
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    88
lemma acc_modi_accmodi_simp[simp]: "accmodi (a::acc_modi) = a"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    89
by (simp add: acc_modi_accmodi_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    90
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    91
instance access_field_type:: ("type","type") has_accmodi
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    92
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    93
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    94
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    95
decl_acc_modi_def: "accmodi (d::('a:: type) decl_scheme) \<equiv> access d"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    96
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    97
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    98
lemma decl_acc_modi_simp[simp]: "accmodi (d::('a::type) decl_scheme) = access d"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
    99
by (simp add: decl_acc_modi_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   100
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   101
instance * :: ("type",has_accmodi) has_accmodi
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   102
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   103
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   104
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   105
pair_acc_modi_def: "accmodi p \<equiv> (accmodi (snd p))"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   106
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   107
lemma pair_acc_modi_simp[simp]: "accmodi (x,a) = (accmodi a)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   108
by (simp add: pair_acc_modi_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   109
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   110
instance memberdecl :: has_accmodi
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   111
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   112
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   113
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   114
memberdecl_acc_modi_def: "accmodi m \<equiv> (case m of
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   115
                                          fdecl f \<Rightarrow> accmodi f
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   116
                                        | mdecl m \<Rightarrow> accmodi m)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   117
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   118
lemma memberdecl_fdecl_acc_modi_simp[simp]:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   119
 "accmodi (fdecl m) = accmodi m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   120
by (simp add: memberdecl_acc_modi_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   121
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   122
lemma memberdecl_mdecl_acc_modi_simp[simp]:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   123
 "accmodi (mdecl m) = accmodi m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   124
by (simp add: memberdecl_acc_modi_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   125
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   126
text {* overloaded selector @{text declclass} to select the declaring class 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   127
out of various HOL types *}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   128
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   129
axclass has_declclass < "type"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   130
consts declclass:: "'a::has_declclass \<Rightarrow> qtname"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   131
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   132
instance pid_field_type::("type","type") has_declclass
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   133
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   134
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   135
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   136
qtname_declclass_def: "declclass (q::qtname) \<equiv> q"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   137
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   138
lemma qtname_declclass_simp[simp]: "declclass (q::qtname) = q"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   139
by (simp add: qtname_declclass_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   140
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   141
instance * :: ("has_declclass","type") has_declclass
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   142
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   143
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   144
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   145
pair_declclass_def: "declclass p \<equiv> declclass (fst p)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   146
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   147
lemma pair_declclass_simp[simp]: "declclass (c,x) = declclass c" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   148
by (simp add: pair_declclass_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   149
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   150
text {* overloaded selector @{text is_static} to select the static modifier 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   151
out of various HOL types *}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   152
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   153
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   154
axclass has_static < "type"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   155
consts is_static :: "'a::has_static \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   156
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   157
(*
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   158
consts is_static :: "'a \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   159
*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   160
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   161
instance access_field_type :: ("type","has_static") has_static
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   162
by (intro_classes) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   163
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   164
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   165
decl_is_static_def: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   166
 "is_static (m::('a::has_static) decl_scheme) \<equiv> is_static (Decl.decl.more m)" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   167
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   168
instance static_field_type :: ("type","type") has_static
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   169
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   170
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   171
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   172
static_field_type_is_static_def: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   173
 "is_static (m::(bool,'b::type) static_field_type) \<equiv> static_val m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   174
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   175
lemma member_is_static_simp: "is_static (m::'a member_scheme) = static m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   176
apply (cases m)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   177
apply (simp add: static_field_type_is_static_def 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   178
                 decl_is_static_def Decl.member.dest_convs)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   179
done
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   180
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   181
instance * :: ("type","has_static") has_static
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   182
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   183
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   184
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   185
pair_is_static_def: "is_static p \<equiv> is_static (snd p)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   186
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   187
lemma pair_is_static_simp [simp]: "is_static (x,s) = is_static s"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   188
by (simp add: pair_is_static_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   189
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   190
lemma pair_is_static_simp1: "is_static p = is_static (snd p)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   191
by (simp add: pair_is_static_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   192
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   193
instance memberdecl:: has_static
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   194
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   195
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   196
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   197
memberdecl_is_static_def: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   198
 "is_static m \<equiv> (case m of
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   199
                    fdecl f \<Rightarrow> is_static f
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   200
                  | mdecl m \<Rightarrow> is_static m)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   201
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   202
lemma memberdecl_is_static_fdecl_simp[simp]:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   203
 "is_static (fdecl f) = is_static f"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   204
by (simp add: memberdecl_is_static_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   205
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   206
lemma memberdecl_is_static_mdecl_simp[simp]:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   207
 "is_static (mdecl m) = is_static m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   208
by (simp add: memberdecl_is_static_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   209
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   210
lemma mhead_static_simp [simp]: "is_static (mhead m) = is_static m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   211
by (cases m) (simp add: mhead_def member_is_static_simp)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   212
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   213
constdefs  (* some mnemotic selectors for (qtname \<times> ('a::more) decl_scheme) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   214
            * the first component is a class or interface name
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   215
            * the second component is a method, field or method head *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   216
(* "declclass":: "(qtname \<times> ('a::more) decl_scheme) \<Rightarrow> qtname"*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   217
(* "declclass \<equiv> fst" *)          (* get the class component *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   218
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   219
 "decliface":: "(qtname \<times> ('a::type) decl_scheme) \<Rightarrow> qtname"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   220
 "decliface \<equiv> fst"          (* get the interface component *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   221
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   222
(*
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   223
 "member"::   "(qtname \<times> ('a::type) decl_scheme) \<Rightarrow> ('a::type) decl_scheme"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   224
*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   225
 "mbr"::   "(qtname \<times> memberdecl) \<Rightarrow> memberdecl"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   226
 "mbr \<equiv> snd"            (* get the memberdecl component *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   227
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   228
 "mthd"::   "('b \<times> 'a) \<Rightarrow> 'a"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   229
                           (* also used for mdecl,mhead *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   230
 "mthd \<equiv> snd"              (* get the method component *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   231
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   232
 "fld"::   "('b \<times> ('a::type) decl_scheme) \<Rightarrow> ('a::type) decl_scheme"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   233
              (* also used for ((vname \<times> qtname)\<times> field) *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   234
 "fld \<equiv> snd"               (* get the field component *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   235
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   236
(* "accmodi" :: "('b \<times> ('a::type) decl_scheme) \<Rightarrow> acc_modi"*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   237
                           (* also used for mdecl *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   238
(* "accmodi \<equiv> access \<circ> snd"*)  (* get the access modifier *) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   239
(*
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   240
 "is_static" ::"('b \<times> ('a::type) member_scheme) \<Rightarrow> bool" *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   241
                            (* also defined for emhead cf. WellType *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   242
 (*"is_static \<equiv> static \<circ> snd"*) (* get the static modifier *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   243
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   244
constdefs (* some mnemotic selectors for (vname \<times> qtname) *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   245
 fname:: "(vname \<times> 'a) \<Rightarrow> vname" (* also used for fdecl *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   246
 "fname \<equiv> fst"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   247
  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   248
  declclassf:: "(vname \<times> qtname) \<Rightarrow> qtname"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   249
 "declclassf \<equiv> snd"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   250
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   251
(*
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   252
lemma declclass_simp[simp]: "declclass (C,m) = C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   253
by (simp add: declclass_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   254
*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   255
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   256
lemma decliface_simp[simp]: "decliface (I,m) = I"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   257
by (simp add: decliface_def) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   258
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   259
lemma mbr_simp[simp]: "mbr (C,m) = m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   260
by (simp add: mbr_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   261
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   262
lemma access_mbr_simp [simp]: "(accmodi (mbr m)) = accmodi m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   263
by (cases m) (simp add:  mbr_def) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   264
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   265
lemma mthd_simp[simp]: "mthd (C,m) = m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   266
by (simp add: mthd_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   267
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   268
lemma fld_simp[simp]: "fld (C,f) = f"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   269
by (simp add: fld_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   270
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   271
lemma accmodi_simp[simp]: "accmodi (C,m) = access m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   272
by (simp )
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   273
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   274
lemma access_mthd_simp [simp]: "(access (mthd m)) = accmodi m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   275
by (cases m) (simp add: mthd_def) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   276
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   277
lemma access_fld_simp [simp]: "(access (fld f)) = accmodi f"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   278
by (cases f) (simp add:  fld_def) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   279
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   280
(*
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   281
lemma is_static_simp[simp]: "is_static (C,m) = static m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   282
by (simp add: is_static_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   283
*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   284
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   285
lemma static_mthd_simp[simp]: "static (mthd m) = is_static m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   286
by (cases m) (simp add:  mthd_def member_is_static_simp)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   287
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   288
lemma mthd_is_static_simp [simp]: "is_static (mthd m) = is_static m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   289
by (cases m) simp
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   290
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   291
lemma static_fld_simp[simp]: "static (fld f) = is_static f"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   292
by (cases f) (simp add:  fld_def member_is_static_simp)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   293
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   294
lemma ext_field_simp [simp]: "(declclass f,fld f) = f"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   295
by (cases f) (simp add:  fld_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   296
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   297
lemma ext_method_simp [simp]: "(declclass m,mthd m) = m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   298
by (cases m) (simp add:  mthd_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   299
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   300
lemma ext_mbr_simp [simp]: "(declclass m,mbr m) = m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   301
by (cases m) (simp add: mbr_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   302
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   303
lemma fname_simp[simp]:"fname (n,c) = n"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   304
by (simp add: fname_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   305
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   306
lemma declclassf_simp[simp]:"declclassf (n,c) = c"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   307
by (simp add: declclassf_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   308
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   309
constdefs  (* some mnemotic selectors for (vname \<times> qtname) *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   310
  "fldname"  :: "(vname \<times> qtname) \<Rightarrow> vname" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   311
  "fldname \<equiv> fst"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   312
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   313
  "fldclass" :: "(vname \<times> qtname) \<Rightarrow> qtname"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   314
  "fldclass \<equiv> snd"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   315
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   316
lemma fldname_simp[simp]: "fldname (n,c) = n"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   317
by (simp add: fldname_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   318
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   319
lemma fldclass_simp[simp]: "fldclass (n,c) = c"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   320
by (simp add: fldclass_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   321
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   322
lemma ext_fieldname_simp[simp]: "(fldname f,fldclass f) = f"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   323
by (simp add: fldname_def fldclass_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   324
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   325
text {* Convert a qualified method declaration (qualified with its declaring 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   326
class) to a qualified member declaration:  @{text methdMembr}  *}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   327
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   328
constdefs
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   329
methdMembr :: "(qtname \<times> mdecl) \<Rightarrow> (qtname \<times> memberdecl)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   330
 "methdMembr m \<equiv> (fst m,mdecl (snd m))"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   331
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   332
lemma methdMembr_simp[simp]: "methdMembr (c,m) = (c,mdecl m)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   333
by (simp add: methdMembr_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   334
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   335
lemma accmodi_methdMembr_simp[simp]: "accmodi (methdMembr m) = accmodi m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   336
by (cases m) (simp add: methdMembr_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   337
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   338
lemma is_static_methdMembr_simp[simp]: "is_static (methdMembr m) = is_static m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   339
by (cases m) (simp add: methdMembr_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   340
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   341
lemma declclass_methdMembr_simp[simp]: "declclass (methdMembr m) = declclass m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   342
by (cases m) (simp add: methdMembr_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   343
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   344
text {* Convert a qualified method (qualified with its declaring 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   345
class) to a qualified member declaration:  @{text method}  *}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   346
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   347
constdefs
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   348
method :: "sig \<Rightarrow> (qtname \<times> methd) \<Rightarrow> (qtname \<times> memberdecl)" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   349
"method sig m \<equiv> (declclass m, mdecl (sig, mthd m))"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   350
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   351
lemma method_simp[simp]: "method sig (C,m) = (C,mdecl (sig,m))"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   352
by (simp add: method_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   353
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   354
lemma accmodi_method_simp[simp]: "accmodi (method sig m) = accmodi m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   355
by (simp add: method_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   356
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   357
lemma declclass_method_simp[simp]: "declclass (method sig m) = declclass m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   358
by (simp add: method_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   359
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   360
lemma is_static_method_simp[simp]: "is_static (method sig m) = is_static m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   361
by (cases m) (simp add: method_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   362
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   363
lemma mbr_method_simp[simp]: "mbr (method sig m) = mdecl (sig,mthd m)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   364
by (simp add: mbr_def method_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   365
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   366
lemma memberid_method_simp[simp]:  "memberid (method sig m) = mid sig"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   367
  by (simp add: method_def) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   368
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   369
constdefs
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   370
fieldm :: "vname \<Rightarrow> (qtname \<times> field) \<Rightarrow> (qtname \<times> memberdecl)" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   371
"fieldm n f \<equiv> (declclass f, fdecl (n, fld f))"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   372
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   373
lemma fieldm_simp[simp]: "fieldm n (C,f) = (C,fdecl (n,f))"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   374
by (simp add: fieldm_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   375
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   376
lemma accmodi_fieldm_simp[simp]: "accmodi (fieldm n f) = accmodi f"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   377
by (simp add: fieldm_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   378
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   379
lemma declclass_fieldm_simp[simp]: "declclass (fieldm n f) = declclass f"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   380
by (simp add: fieldm_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   381
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   382
lemma is_static_fieldm_simp[simp]: "is_static (fieldm n f) = is_static f"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   383
by (cases f) (simp add: fieldm_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   384
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   385
lemma mbr_fieldm_simp[simp]: "mbr (fieldm n f) = fdecl (n,fld f)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   386
by (simp add: mbr_def fieldm_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   387
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   388
lemma memberid_fieldm_simp[simp]:  "memberid (fieldm n f) = fid n"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   389
by (simp add: fieldm_def) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   390
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   391
text {* Select the signature out of a qualified method declaration:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   392
 @{text msig} *}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   393
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   394
constdefs msig:: "(qtname \<times> mdecl) \<Rightarrow> sig"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   395
"msig m \<equiv> fst (snd m)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   396
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   397
lemma msig_simp[simp]: "msig (c,(s,m)) = s"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   398
by (simp add: msig_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   399
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   400
text {* Convert a qualified method (qualified with its declaring 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   401
class) to a qualified method declaration:  @{text qmdecl}  *}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   402
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   403
constdefs qmdecl :: "sig \<Rightarrow> (qtname \<times> methd) \<Rightarrow> (qtname \<times> mdecl)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   404
"qmdecl sig m \<equiv> (declclass m, (sig,mthd m))"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   405
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   406
lemma qmdecl_simp[simp]: "qmdecl sig (C,m) = (C,(sig,m))"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   407
by (simp add: qmdecl_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   408
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   409
lemma declclass_qmdecl_simp[simp]: "declclass (qmdecl sig m) = declclass m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   410
by (simp add: qmdecl_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   411
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   412
lemma accmodi_qmdecl_simp[simp]: "accmodi (qmdecl sig m) = accmodi m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   413
by (simp add: qmdecl_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   414
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   415
lemma is_static_qmdecl_simp[simp]: "is_static (qmdecl sig m) = is_static m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   416
by (cases m) (simp add: qmdecl_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   417
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   418
lemma msig_qmdecl_simp[simp]: "msig (qmdecl sig m) = sig"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   419
by (simp add: qmdecl_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   420
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   421
lemma mdecl_qmdecl_simp[simp]:  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   422
 "mdecl (mthd (qmdecl sig new)) = mdecl (sig, mthd new)" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   423
by (simp add: qmdecl_def) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   424
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   425
lemma methdMembr_qmdecl_simp [simp]: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   426
 "methdMembr (qmdecl sig old) = method sig old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   427
by (simp add: methdMembr_def qmdecl_def method_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   428
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   429
text {* overloaded selector @{text resTy} to select the result type 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   430
out of various HOL types *}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   431
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   432
axclass has_resTy < "type"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   433
consts resTy:: "'a::has_resTy \<Rightarrow> ty"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   434
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   435
instance access_field_type :: ("type","has_resTy") has_resTy
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   436
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   437
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   438
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   439
decl_resTy_def: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   440
 "resTy (m::('a::has_resTy) decl_scheme) \<equiv> resTy (Decl.decl.more m)" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   441
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   442
instance static_field_type :: ("type","has_resTy") has_resTy
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   443
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   444
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   445
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   446
static_field_type_resTy_def: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   447
 "resTy (m::(bool,'b::has_resTy) static_field_type) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   448
  \<equiv> resTy (static_more m)" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   449
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   450
instance pars_field_type :: ("type","has_resTy") has_resTy
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   451
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   452
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   453
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   454
pars_field_type_resTy_def: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   455
 "resTy (m::(vname list,'b::has_resTy) pars_field_type) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   456
  \<equiv> resTy (pars_more m)" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   457
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   458
instance resT_field_type :: ("type","type") has_resTy
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   459
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   460
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   461
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   462
resT_field_type_resTy_def: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   463
 "resTy (m::(ty,'b::type) resT_field_type) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   464
  \<equiv> resT_val m" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   465
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   466
lemma mhead_resTy_simp: "resTy (m::'a mhead_scheme) = resT m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   467
apply (cases m)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   468
apply (simp add: decl_resTy_def static_field_type_resTy_def 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   469
                 pars_field_type_resTy_def resT_field_type_resTy_def
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   470
                 member.dest_convs mhead.dest_convs)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   471
done
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   472
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   473
lemma resTy_mhead [simp]:"resTy (mhead m) = resTy m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   474
by (simp add: mhead_def mhead_resTy_simp)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   475
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   476
instance * :: ("type","has_resTy") has_resTy
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   477
by (intro_classes)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   478
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   479
defs (overloaded)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   480
pair_resTy_def: "resTy p \<equiv> resTy (snd p)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   481
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   482
lemma pair_resTy_simp[simp]: "resTy (x,m) = resTy m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   483
by (simp add: pair_resTy_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   484
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   485
lemma qmdecl_resTy_simp [simp]: "resTy (qmdecl sig m) = resTy m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   486
by (cases m) (simp)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   487
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   488
lemma resTy_mthd [simp]:"resTy (mthd m) = resTy m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   489
by (cases m) (simp add: mthd_def )
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   490
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   491
subsubsection "inheritable-in"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   492
text {*
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   493
@{text "G\<turnstile>m inheritable_in P"}: m can be inherited by
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   494
classes in package P if:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   495
\begin{itemize} 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   496
\item the declaration class of m is accessible in P and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   497
\item the member m is declared with protected or public access or if it is
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   498
      declared with default (package) access, the package of the declaration 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   499
      class of m is also P. If the member m is declared with private access
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   500
      it is not accessible for inheritance at all.
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   501
\end{itemize}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   502
*}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   503
constdefs
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   504
inheritable_in:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   505
 "prog \<Rightarrow> (qtname \<times> memberdecl) \<Rightarrow> pname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   506
                  ("_ \<turnstile> _ inheritable'_in _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   507
"G\<turnstile>membr inheritable_in pack 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   508
  \<equiv> (case (accmodi membr) of
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   509
       Private   \<Rightarrow> False
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   510
     | Package   \<Rightarrow> (pid (declclass membr)) = pack
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   511
     | Protected \<Rightarrow> True
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   512
     | Public    \<Rightarrow> True)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   513
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   514
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   515
Method_inheritable_in::
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   516
 "prog \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> pname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   517
                ("_ \<turnstile>Method _ inheritable'_in _ " [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   518
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   519
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   520
"G\<turnstile>Method m inheritable_in p" == "G\<turnstile>methdMembr m inheritable_in p"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   521
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   522
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   523
Methd_inheritable_in::
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   524
 "prog \<Rightarrow> sig \<Rightarrow> (qtname \<times> methd) \<Rightarrow> pname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   525
                ("_ \<turnstile>Methd _ _ inheritable'_in _ " [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   526
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   527
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   528
"G\<turnstile>Methd s m inheritable_in p" == "G\<turnstile>(method s m) inheritable_in p"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   529
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   530
subsubsection "declared-in/undeclared-in"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   531
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   532
constdefs cdeclaredmethd:: "prog \<Rightarrow> qtname \<Rightarrow> (sig,methd) table"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   533
"cdeclaredmethd G C 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   534
  \<equiv> (case class G C of
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   535
       None \<Rightarrow> \<lambda> sig. None
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   536
     | Some c \<Rightarrow> table_of (methods c)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   537
    )"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   538
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   539
constdefs
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   540
cdeclaredfield:: "prog \<Rightarrow> qtname \<Rightarrow> (vname,field) table"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   541
"cdeclaredfield G C 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   542
  \<equiv> (case class G C of
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   543
       None \<Rightarrow> \<lambda> sig. None
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   544
     | Some c \<Rightarrow> table_of (cfields c)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   545
    )"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   546
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   547
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   548
constdefs
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   549
declared_in:: "prog  \<Rightarrow> memberdecl \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   550
                                 ("_\<turnstile> _ declared'_in _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   551
"G\<turnstile>m declared_in C \<equiv> (case m of
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   552
                        fdecl (fn,f ) \<Rightarrow> cdeclaredfield G C fn  = Some f
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   553
                      | mdecl (sig,m) \<Rightarrow> cdeclaredmethd G C sig = Some m)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   554
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   555
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   556
method_declared_in:: "prog  \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   557
                                 ("_\<turnstile>Method _ declared'_in _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   558
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   559
"G\<turnstile>Method m declared_in C" == "G\<turnstile>mdecl (mthd m) declared_in C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   560
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   561
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   562
methd_declared_in:: "prog  \<Rightarrow> sig  \<Rightarrow>(qtname \<times> methd) \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   563
                               ("_\<turnstile>Methd _  _ declared'_in _" [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   564
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   565
"G\<turnstile>Methd s m declared_in C" == "G\<turnstile>mdecl (s,mthd m) declared_in C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   566
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   567
lemma declared_in_classD:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   568
 "G\<turnstile>m declared_in C \<Longrightarrow> is_class G C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   569
by (cases m) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   570
   (auto simp add: declared_in_def cdeclaredmethd_def cdeclaredfield_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   571
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   572
constdefs
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   573
undeclared_in:: "prog  \<Rightarrow> memberid \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   574
                                 ("_\<turnstile> _ undeclared'_in _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   575
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   576
"G\<turnstile>m undeclared_in C \<equiv> (case m of
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   577
                            fid fn  \<Rightarrow> cdeclaredfield G C fn  = None
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   578
                          | mid sig \<Rightarrow> cdeclaredmethd G C sig = None)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   579
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   580
lemma method_declared_inI:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   581
  "\<lbrakk>class G C = Some c; table_of (methods c) sig = Some m\<rbrakk> 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   582
   \<Longrightarrow> G\<turnstile>mdecl (sig,m) declared_in C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   583
by (auto simp add: declared_in_def cdeclaredmethd_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   584
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   585
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   586
subsubsection "members"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   587
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   588
consts
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   589
members:: "prog \<Rightarrow> (qtname \<times> (qtname \<times> memberdecl)) set"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   590
(* Can't just take a function: prog \<Rightarrow> qtname \<Rightarrow> memberdecl set because
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   591
   the class qtname changes to the superclass in the inductive definition
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   592
   below
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   593
*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   594
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   595
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   596
member_of:: "prog \<Rightarrow> (qtname \<times> memberdecl) \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   597
                           ("_ \<turnstile> _ member'_of _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   598
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   599
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   600
 "G\<turnstile>m member_of C" \<rightleftharpoons> "(C,m) \<in> members G"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   601
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   602
inductive "members G"  intros
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   603
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   604
Immediate: "\<lbrakk>G\<turnstile>mbr m declared_in C;declclass m = C\<rbrakk> \<Longrightarrow> G\<turnstile>m member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   605
Inherited: "\<lbrakk>G\<turnstile>m inheritable_in (pid C); G\<turnstile>memberid m undeclared_in C; 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   606
             G\<turnstile>C \<prec>\<^sub>C\<^sub>1 S; G\<turnstile>(Class S) accessible_in (pid C);G\<turnstile>m member_of S 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   607
            \<rbrakk> \<Longrightarrow> G\<turnstile>m member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   608
text {* Note that in the case of an inherited member only the members of the
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   609
direct superclass are concerned. If a member of a superclass of the direct
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   610
superclass isn't inherited in the direct superclass (not member of the
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   611
direct superclass) than it can't be a member of the class. E.g. If a
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   612
member of a class A is defined with package access it isn't member of a 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   613
subclass S if S isn't in the same package as A. Any further subclasses 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   614
of S will not inherit the member, regardless if they are in the same
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   615
package as A or not.*}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   616
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   617
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   618
method_member_of:: "prog \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   619
                           ("_ \<turnstile>Method _ member'_of _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   620
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   621
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   622
 "G\<turnstile>Method m member_of C" \<rightleftharpoons> "G\<turnstile>(methdMembr m) member_of C" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   623
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   624
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   625
methd_member_of:: "prog \<Rightarrow> sig \<Rightarrow> (qtname \<times> methd) \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   626
                           ("_ \<turnstile>Methd _ _ member'_of _" [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   627
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   628
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   629
 "G\<turnstile>Methd s m member_of C" \<rightleftharpoons> "G\<turnstile>(method s m) member_of C" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   630
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   631
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   632
fieldm_member_of:: "prog \<Rightarrow> vname \<Rightarrow> (qtname \<times> field) \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   633
                           ("_ \<turnstile>Field _  _ member'_of _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   634
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   635
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   636
 "G\<turnstile>Field n f member_of C" \<rightleftharpoons> "G\<turnstile>fieldm n f member_of C" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   637
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   638
constdefs
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   639
inherits:: "prog \<Rightarrow> qtname \<Rightarrow> (qtname \<times> memberdecl) \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   640
                           ("_ \<turnstile> _ inherits _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   641
"G\<turnstile>C inherits m 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   642
  \<equiv> G\<turnstile>m inheritable_in (pid C) \<and> G\<turnstile>memberid m undeclared_in C \<and> 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   643
    (\<exists> S. G\<turnstile>C \<prec>\<^sub>C\<^sub>1 S \<and> G\<turnstile>(Class S) accessible_in (pid C) \<and> G\<turnstile>m member_of S)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   644
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   645
lemma inherits_member: "G\<turnstile>C inherits m \<Longrightarrow> G\<turnstile>m member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   646
by (auto simp add: inherits_def intro: members.Inherited)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   647
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   648
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   649
constdefs member_in::"prog \<Rightarrow> (qtname \<times> memberdecl) \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   650
                           ("_ \<turnstile> _ member'_in _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   651
"G\<turnstile>m member_in C \<equiv> \<exists> provC. G\<turnstile> C \<preceq>\<^sub>C provC \<and> G \<turnstile> m member_of provC"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   652
text {* A member is in a class if it is member of the class or a superclass.
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   653
If a member is in a class we can select this member. This additional notion
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   654
is necessary since not all members are inherited to subclasses. So such
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   655
members are not member-of the subclass but member-in the subclass.*}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   656
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   657
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   658
method_member_in:: "prog \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   659
                           ("_ \<turnstile>Method _ member'_in _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   660
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   661
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   662
 "G\<turnstile>Method m member_in C" \<rightleftharpoons> "G\<turnstile>(methdMembr m) member_in C" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   663
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   664
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   665
methd_member_in:: "prog \<Rightarrow> sig \<Rightarrow> (qtname \<times> methd) \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   666
                           ("_ \<turnstile>Methd _ _ member'_in _" [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   667
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   668
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   669
 "G\<turnstile>Methd s m member_in C" \<rightleftharpoons> "G\<turnstile>(method s m) member_in C" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   670
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   671
consts stat_overridesR::
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   672
  "prog  \<Rightarrow> ((qtname \<times> mdecl) \<times> (qtname \<times> mdecl)) set"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   673
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   674
lemma member_inD: "G\<turnstile>m member_in C 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   675
 \<Longrightarrow> \<exists> provC. G\<turnstile> C \<preceq>\<^sub>C provC \<and> G \<turnstile> m member_of provC"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   676
by (auto simp add: member_in_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   677
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   678
lemma member_inI: "\<lbrakk>G \<turnstile> m member_of provC;G\<turnstile> C \<preceq>\<^sub>C provC\<rbrakk> \<Longrightarrow>  G\<turnstile>m member_in C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   679
by (auto simp add: member_in_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   680
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   681
lemma member_of_to_member_in: "G \<turnstile> m member_of C \<Longrightarrow> G \<turnstile>m member_in C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   682
by (auto intro: member_inI)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   683
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   684
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   685
subsubsection "overriding"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   686
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   687
text {* Unfortunately the static notion of overriding (used during the
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   688
typecheck of the compiler) and the dynamic notion of overriding (used during
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   689
execution in the JVM) are not exactly the same. 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   690
*}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   691
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   692
text {* Static overriding (used during the typecheck of the compiler) *}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   693
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   694
stat_overrides:: "prog  \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> bool" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   695
                                  ("_ \<turnstile> _ overrides\<^sub>S _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   696
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   697
 "G\<turnstile>new overrides\<^sub>S  old" == "(new,old) \<in> stat_overridesR G "
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   698
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   699
inductive "stat_overridesR G" intros
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   700
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   701
Direct: "\<lbrakk>\<not> is_static new; msig new = msig old; 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   702
         G\<turnstile>(declclass new) \<prec>\<^sub>C (declclass old);
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   703
         G\<turnstile>Method new declared_in (declclass new);  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   704
         G\<turnstile>Method old declared_in (declclass old); 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   705
         G\<turnstile>Method old inheritable_in pid (declclass new);
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   706
         G\<turnstile>(declclass new) \<prec>\<^sub>C\<^sub>1 superNew;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   707
         G \<turnstile>Method old member_of superNew
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   708
         \<rbrakk> \<Longrightarrow> G\<turnstile>new overrides\<^sub>S old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   709
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   710
Indirect: "\<lbrakk>G\<turnstile>new overrides\<^sub>S inter; G\<turnstile>inter overrides\<^sub>S old\<rbrakk>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   711
           \<Longrightarrow> G\<turnstile>new overrides\<^sub>S old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   712
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   713
text {* Dynamic overriding (used during the typecheck of the compiler) *}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   714
consts overridesR::
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   715
  "prog  \<Rightarrow> ((qtname \<times> mdecl) \<times> (qtname \<times> mdecl)) set"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   716
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   717
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   718
overrides:: "prog  \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> bool" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   719
                                  ("_ \<turnstile> _ overrides _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   720
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   721
 "G\<turnstile>new overrides old" == "(new,old) \<in> overridesR G "
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   722
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   723
inductive "overridesR G" intros
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   724
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   725
Direct: "\<lbrakk>\<not> is_static new; \<not> is_static old; accmodi new \<noteq> Private;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   726
         msig new = msig old; 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   727
         G\<turnstile>(declclass new) \<prec>\<^sub>C (declclass old);
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   728
         G\<turnstile>Method new declared_in (declclass new);  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   729
         G\<turnstile>Method old declared_in (declclass old);    
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   730
         G\<turnstile>Method old inheritable_in pid (declclass new);
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   731
         G\<turnstile>resTy new \<preceq> resTy old
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   732
         \<rbrakk> \<Longrightarrow> G\<turnstile>new overrides old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   733
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   734
Indirect: "\<lbrakk>G\<turnstile>new overrides inter; G\<turnstile>inter overrides old\<rbrakk>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   735
           \<Longrightarrow> G\<turnstile>new overrides old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   736
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   737
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   738
sig_stat_overrides:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   739
 "prog  \<Rightarrow> sig \<Rightarrow> (qtname \<times> methd) \<Rightarrow> (qtname \<times> methd) \<Rightarrow> bool" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   740
                                  ("_,_\<turnstile> _ overrides\<^sub>S _" [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   741
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   742
 "G,s\<turnstile>new overrides\<^sub>S old" \<rightharpoonup> "G\<turnstile>(qmdecl s new) overrides\<^sub>S (qmdecl s old)" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   743
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   744
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   745
sig_overrides:: "prog  \<Rightarrow> sig \<Rightarrow> (qtname \<times> methd) \<Rightarrow> (qtname \<times> methd) \<Rightarrow> bool" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   746
                                  ("_,_\<turnstile> _ overrides _" [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   747
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   748
 "G,s\<turnstile>new overrides old" \<rightharpoonup> "G\<turnstile>(qmdecl s new) overrides (qmdecl s old)" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   749
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   750
subsubsection "Hiding"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   751
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   752
constdefs hides::
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   753
"prog \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> bool" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   754
                                ("_\<turnstile> _ hides _" [61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   755
"G\<turnstile>new hides old
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   756
  \<equiv> is_static new \<and> msig new = msig old \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   757
    G\<turnstile>(declclass new) \<prec>\<^sub>C (declclass old) \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   758
    G\<turnstile>Method new declared_in (declclass new) \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   759
    G\<turnstile>Method old declared_in (declclass old) \<and> 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   760
    G\<turnstile>Method old inheritable_in pid (declclass new)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   761
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   762
syntax
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   763
sig_hides:: "prog  \<Rightarrow> sig \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> bool" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   764
                                  ("_,_\<turnstile> _ hides _" [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   765
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   766
 "G,s\<turnstile>new hides old" \<rightharpoonup> "G\<turnstile>(qmdecl s new) hides (qmdecl s old)" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   767
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   768
lemma hidesI:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   769
"\<lbrakk>is_static new; msig new = msig old;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   770
  G\<turnstile>(declclass new) \<prec>\<^sub>C (declclass old);
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   771
  G\<turnstile>Method new declared_in (declclass new);
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   772
  G\<turnstile>Method old declared_in (declclass old);
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   773
  G\<turnstile>Method old inheritable_in pid (declclass new)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   774
 \<rbrakk> \<Longrightarrow> G\<turnstile>new hides old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   775
by (auto simp add: hides_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   776
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   777
lemma hidesD:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   778
"\<lbrakk>G\<turnstile>new hides old\<rbrakk> \<Longrightarrow>  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   779
  declclass new \<noteq> Object \<and> is_static new \<and> msig new = msig old \<and> 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   780
  G\<turnstile>(declclass new) \<prec>\<^sub>C (declclass old) \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   781
  G\<turnstile>Method new declared_in (declclass new) \<and>   
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   782
  G\<turnstile>Method old declared_in (declclass old)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   783
by (auto simp add: hides_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   784
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   785
lemma overrides_commonD:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   786
"\<lbrakk>G\<turnstile>new overrides old\<rbrakk> \<Longrightarrow>  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   787
  declclass new \<noteq> Object \<and> \<not> is_static new \<and> \<not> is_static old \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   788
  accmodi new \<noteq> Private \<and> 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   789
  msig new = msig old  \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   790
  G\<turnstile>(declclass new) \<prec>\<^sub>C (declclass old) \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   791
  G\<turnstile>Method new declared_in (declclass new) \<and>   
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   792
  G\<turnstile>Method old declared_in (declclass old)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   793
by (induct set: overridesR) (auto intro: trancl_trans)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   794
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   795
lemma ws_overrides_commonD:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   796
"\<lbrakk>G\<turnstile>new overrides old;ws_prog G\<rbrakk> \<Longrightarrow>  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   797
  declclass new \<noteq> Object \<and> \<not> is_static new \<and> \<not> is_static old \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   798
  accmodi new \<noteq> Private \<and> G\<turnstile>resTy new \<preceq> resTy old \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   799
  msig new = msig old  \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   800
  G\<turnstile>(declclass new) \<prec>\<^sub>C (declclass old) \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   801
  G\<turnstile>Method new declared_in (declclass new) \<and>   
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   802
  G\<turnstile>Method old declared_in (declclass old)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   803
by (induct set: overridesR) (auto intro: trancl_trans ws_widen_trans)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   804
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   805
lemma stat_overrides_commonD:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   806
"\<lbrakk>G\<turnstile>new overrides\<^sub>S old\<rbrakk> \<Longrightarrow>  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   807
  declclass new \<noteq> Object \<and> \<not> is_static new \<and> msig new = msig old \<and> 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   808
  G\<turnstile>(declclass new) \<prec>\<^sub>C (declclass old) \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   809
  G\<turnstile>Method new declared_in (declclass new) \<and>   
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   810
  G\<turnstile>Method old declared_in (declclass old)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   811
by (induct set: stat_overridesR) (auto intro: trancl_trans)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   812
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   813
lemma overrides_eq_sigD: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   814
 "\<lbrakk>G\<turnstile>new overrides old\<rbrakk> \<Longrightarrow> msig old=msig new"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   815
by (auto dest: overrides_commonD)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   816
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   817
lemma hides_eq_sigD: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   818
 "\<lbrakk>G\<turnstile>new hides old\<rbrakk> \<Longrightarrow> msig old=msig new"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   819
by (auto simp add: hides_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   820
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   821
subsubsection "permits access" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   822
constdefs 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   823
permits_acc:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   824
 "prog \<Rightarrow> (qtname \<times> memberdecl) \<Rightarrow> qtname \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   825
                   ("_ \<turnstile> _ in _ permits'_acc'_to _" [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   826
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   827
"G\<turnstile>membr in class permits_acc_to accclass 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   828
  \<equiv> (case (accmodi membr) of
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   829
       Private   \<Rightarrow> (declclass membr = accclass)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   830
     | Package   \<Rightarrow> (pid (declclass membr) = pid accclass)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   831
     | Protected \<Rightarrow> (pid (declclass membr) = pid accclass)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   832
                    \<or>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   833
                    (G\<turnstile>accclass \<prec>\<^sub>C declclass membr \<and> G\<turnstile>class \<preceq>\<^sub>C accclass) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   834
     | Public    \<Rightarrow> True)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   835
text {*
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   836
The subcondition of the @{term "Protected"} case: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   837
@{term "G\<turnstile>accclass \<prec>\<^sub>C declclass membr"} could also be relaxed to:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   838
@{term "G\<turnstile>accclass \<preceq>\<^sub>C declclass membr"} since in case both classes are the
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   839
same the other condition @{term "(pid (declclass membr) = pid accclass)"}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   840
holds anyway.
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   841
*} 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   842
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   843
text {* Like in case of overriding, the static and dynamic accessibility 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   844
of members is not uniform.
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   845
\begin{itemize}
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   846
\item Statically the class/interface of the member must be accessible for the
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   847
      member to be accessible. During runtime this is not necessary. For
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   848
      Example, if a class is accessible and we are allowed to access a member
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   849
      of this class (statically) we expect that we can access this member in 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   850
      an arbitrary subclass (during runtime). It's not intended to restrict
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   851
      the access to accessible subclasses during runtime.
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   852
\item Statically the member we want to access must be "member of" the class.
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   853
      Dynamically it must only be "member in" the class.
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   854
\end{itemize} 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   855
*} 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   856
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   857
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   858
consts
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   859
accessible_fromR:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   860
 "prog \<Rightarrow> qtname \<Rightarrow> ((qtname \<times> memberdecl) \<times>  qtname) set"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   861
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   862
syntax 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   863
accessible_from:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   864
 "prog \<Rightarrow> (qtname \<times> memberdecl) \<Rightarrow> qtname \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   865
                   ("_ \<turnstile> _ of _ accessible'_from _" [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   866
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   867
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   868
"G\<turnstile>membr of cls accessible_from accclass"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   869
 \<rightleftharpoons> "(membr,cls) \<in> accessible_fromR G accclass"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   870
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   871
syntax 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   872
method_accessible_from:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   873
 "prog \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> qtname \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   874
                   ("_ \<turnstile>Method _ of _ accessible'_from _" [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   875
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   876
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   877
"G\<turnstile>Method m of cls accessible_from accclass"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   878
 \<rightleftharpoons> "G\<turnstile>methdMembr m of cls accessible_from accclass"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   879
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   880
syntax 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   881
methd_accessible_from:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   882
 "prog \<Rightarrow> sig \<Rightarrow> (qtname \<times> methd) \<Rightarrow> qtname \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   883
                 ("_ \<turnstile>Methd _ _ of _ accessible'_from _" [61,61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   884
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   885
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   886
"G\<turnstile>Methd s m of cls accessible_from accclass"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   887
 \<rightleftharpoons> "G\<turnstile>(method s m) of cls accessible_from accclass"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   888
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   889
syntax 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   890
field_accessible_from:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   891
 "prog \<Rightarrow> vname \<Rightarrow> (qtname \<times> field) \<Rightarrow> qtname \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   892
                 ("_ \<turnstile>Field _  _ of _ accessible'_from _" [61,61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   893
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   894
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   895
"G\<turnstile>Field fn f of C accessible_from accclass"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   896
 \<rightleftharpoons> "G\<turnstile>(fieldm fn f) of C accessible_from accclass" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   897
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   898
inductive "accessible_fromR G accclass" intros
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   899
immediate:  "\<lbrakk>G\<turnstile>membr member_of class;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   900
              G\<turnstile>(Class class) accessible_in (pid accclass);
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   901
              G\<turnstile>membr in class permits_acc_to accclass 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   902
             \<rbrakk> \<Longrightarrow> G\<turnstile>membr of class accessible_from accclass"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   903
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   904
overriding: "\<lbrakk>G\<turnstile>membr member_of class;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   905
              G\<turnstile>(Class class) accessible_in (pid accclass);
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   906
              membr=(C,mdecl new);
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   907
              G\<turnstile>(C,new) overrides\<^sub>S old; 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   908
              G\<turnstile>class \<prec>\<^sub>C sup;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   909
              G\<turnstile>Method old of sup accessible_from accclass
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   910
             \<rbrakk>\<Longrightarrow> G\<turnstile>membr of class accessible_from accclass"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   911
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   912
consts
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   913
dyn_accessible_fromR:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   914
 "prog \<Rightarrow> qtname \<Rightarrow> ((qtname \<times> memberdecl) \<times>  qtname) set"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   915
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   916
syntax 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   917
dyn_accessible_from:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   918
 "prog \<Rightarrow> (qtname \<times> memberdecl) \<Rightarrow> qtname \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   919
                   ("_ \<turnstile> _ in _ dyn'_accessible'_from _" [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   920
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   921
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   922
"G\<turnstile>membr in C dyn_accessible_from accC"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   923
 \<rightleftharpoons> "(membr,C) \<in> dyn_accessible_fromR G accC"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   924
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   925
syntax 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   926
method_dyn_accessible_from:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   927
 "prog \<Rightarrow> (qtname \<times> mdecl) \<Rightarrow> qtname \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   928
                 ("_ \<turnstile>Method _ in _ dyn'_accessible'_from _" [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   929
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   930
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   931
"G\<turnstile>Method m in C dyn_accessible_from accC"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   932
 \<rightleftharpoons> "G\<turnstile>methdMembr m in C dyn_accessible_from accC"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   933
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   934
syntax 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   935
methd_dyn_accessible_from:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   936
 "prog \<Rightarrow> sig \<Rightarrow> (qtname \<times> methd) \<Rightarrow> qtname \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   937
             ("_ \<turnstile>Methd _ _ in _ dyn'_accessible'_from _" [61,61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   938
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   939
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   940
"G\<turnstile>Methd s m in C dyn_accessible_from accC"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   941
 \<rightleftharpoons> "G\<turnstile>(method s m) in C dyn_accessible_from accC"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   942
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   943
syntax 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   944
field_dyn_accessible_from:: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   945
 "prog \<Rightarrow> vname \<Rightarrow> (qtname \<times> field) \<Rightarrow> qtname \<Rightarrow> qtname \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   946
         ("_ \<turnstile>Field _ _ in _ dyn'_accessible'_from _" [61,61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   947
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   948
translations
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   949
"G\<turnstile>Field fn f in dynC dyn_accessible_from accC"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   950
 \<rightleftharpoons> "G\<turnstile>(fieldm fn f) in dynC dyn_accessible_from accC"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   951
  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   952
(* #### Testet JVM noch über den Bytecodeverifier hinaus ob der
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   953
 statische Typ accessible ist bevor es den Zugriff erlaubt 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   954
 \<longrightarrow> Test mit Reflektion\<dots>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   955
*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   956
inductive "dyn_accessible_fromR G accclass" intros
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   957
immediate:  "\<lbrakk>G\<turnstile>membr member_in class;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   958
              G\<turnstile>membr in class permits_acc_to accclass 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   959
             \<rbrakk> \<Longrightarrow> G\<turnstile>membr in class dyn_accessible_from accclass"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   960
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   961
overriding: "\<lbrakk>G\<turnstile>membr member_in class;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   962
              membr=(C,mdecl new);
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   963
              G\<turnstile>(C,new) overrides old; 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   964
              G\<turnstile>class \<prec>\<^sub>C sup;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   965
              G\<turnstile>Method old in sup dyn_accessible_from accclass
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   966
             \<rbrakk>\<Longrightarrow> G\<turnstile>membr in class dyn_accessible_from accclass"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   967
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   968
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   969
lemma accessible_from_commonD: "G\<turnstile>m of C accessible_from S
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   970
 \<Longrightarrow> G\<turnstile>m member_of C \<and> G\<turnstile>(Class C) accessible_in (pid S)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   971
by (auto elim: accessible_fromR.induct)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   972
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   973
lemma declared_not_undeclared:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   974
  "G\<turnstile>m declared_in C \<Longrightarrow> \<not> G\<turnstile> memberid m undeclared_in C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   975
by (cases m) (auto simp add: declared_in_def undeclared_in_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   976
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   977
lemma not_undeclared_declared:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   978
  "\<not> G\<turnstile> membr_id undeclared_in C \<Longrightarrow> (\<exists> m. G\<turnstile>m declared_in C \<and> 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   979
                                           membr_id = memberid m)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   980
proof -
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   981
  assume not_undecl:"\<not> G\<turnstile> membr_id undeclared_in C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   982
  show ?thesis (is "?P membr_id")
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   983
  proof (cases membr_id)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   984
    case (fid vname)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   985
    with not_undecl
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   986
    obtain fld where
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   987
      "G\<turnstile>fdecl (vname,fld) declared_in C" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   988
      by (auto simp add: undeclared_in_def declared_in_def
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   989
                         cdeclaredfield_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   990
    with fid show ?thesis 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   991
      by auto
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   992
  next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   993
    case (mid sig)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   994
    with not_undecl
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   995
    obtain mthd where
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   996
      "G\<turnstile>mdecl (sig,mthd) declared_in C" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   997
      by (auto simp add: undeclared_in_def declared_in_def
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   998
                         cdeclaredmethd_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
   999
    with mid show ?thesis 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1000
      by auto
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1001
  qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1002
qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1003
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1004
lemma unique_declared_in:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1005
 "\<lbrakk>G\<turnstile>m declared_in C; G\<turnstile>n declared_in C; memberid m = memberid n\<rbrakk>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1006
 \<Longrightarrow> m = n"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1007
by (auto simp add: declared_in_def cdeclaredmethd_def cdeclaredfield_def
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1008
            split: memberdecl.splits)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1009
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1010
lemma unique_member_of: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1011
 (assumes n: "G\<turnstile>n member_of C" and  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1012
          m: "G\<turnstile>m member_of C" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1013
       eqid: "memberid n = memberid m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1014
 ) "n=m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1015
proof -
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1016
  from n m eqid  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1017
  show "n=m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1018
  proof (induct)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1019
    case (Immediate C n)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1020
    assume member_n: "G\<turnstile> mbr n declared_in C" "declclass n = C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1021
    assume eqid: "memberid n = memberid m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1022
    assume "G \<turnstile> m member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1023
    then show "n=m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1024
    proof (cases)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1025
      case (Immediate _ m')
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1026
      with eqid 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1027
      have "m=m'"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1028
           "memberid n = memberid m" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1029
           "G\<turnstile> mbr m declared_in C" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1030
           "declclass m = C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1031
	by auto
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1032
      with member_n   
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1033
      show ?thesis
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1034
	by (cases n, cases m) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1035
           (auto simp add: declared_in_def 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1036
                           cdeclaredmethd_def cdeclaredfield_def
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1037
                    split: memberdecl.splits)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1038
    next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1039
      case (Inherited _ _ m')
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1040
      then have "G\<turnstile> memberid m undeclared_in C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1041
	by simp
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1042
      with eqid member_n
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1043
      show ?thesis
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1044
	by (cases n) (auto dest: declared_not_undeclared)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1045
    qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1046
  next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1047
    case (Inherited C S n)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1048
    assume undecl: "G\<turnstile> memberid n undeclared_in C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1049
    assume  super: "G\<turnstile>C\<prec>\<^sub>C\<^sub>1S"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1050
    assume    hyp: "\<lbrakk>G \<turnstile> m member_of S; memberid n = memberid m\<rbrakk> \<Longrightarrow> n = m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1051
    assume   eqid: "memberid n = memberid m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1052
    assume "G \<turnstile> m member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1053
    then show "n=m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1054
    proof (cases)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1055
      case Immediate
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1056
      then have "G\<turnstile> mbr m declared_in C" by simp
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1057
      with eqid undecl
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1058
      show ?thesis
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1059
	by (cases m) (auto dest: declared_not_undeclared)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1060
    next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1061
      case Inherited 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1062
      with super have "G \<turnstile> m member_of S"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1063
	by (auto dest!: subcls1D)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1064
      with eqid hyp
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1065
      show ?thesis 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1066
	by blast
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1067
    qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1068
  qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1069
qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1070
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1071
lemma member_of_is_classD: "G\<turnstile>m member_of C \<Longrightarrow> is_class G C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1072
proof (induct set: members)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1073
  case (Immediate C m)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1074
  assume "G\<turnstile> mbr m declared_in C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1075
  then show "is_class G C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1076
    by (cases "mbr m")
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1077
       (auto simp add: declared_in_def cdeclaredmethd_def cdeclaredfield_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1078
next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1079
  case (Inherited C S m)  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1080
  assume "G\<turnstile>C\<prec>\<^sub>C\<^sub>1S" and "is_class G S"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1081
  then show "is_class G C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1082
    by - (rule subcls_is_class2,auto)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1083
qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1084
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1085
lemma member_of_declC: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1086
 "G\<turnstile>m member_of C 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1087
  \<Longrightarrow> G\<turnstile>mbr m declared_in (declclass m)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1088
by (induct set: members) auto
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1089
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1090
lemma member_of_member_of_declC:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1091
 "G\<turnstile>m member_of C 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1092
  \<Longrightarrow> G\<turnstile>m member_of (declclass m)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1093
by (auto dest: member_of_declC intro: members.Immediate)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1094
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1095
lemma member_of_class_relation:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1096
  "G\<turnstile>m member_of C \<Longrightarrow> G\<turnstile>C \<preceq>\<^sub>C declclass m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1097
proof (induct set: members)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1098
  case (Immediate C m)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1099
  then show "G\<turnstile>C \<preceq>\<^sub>C declclass m" by simp
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1100
next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1101
  case (Inherited C S m)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1102
  then show "G\<turnstile>C \<preceq>\<^sub>C declclass m" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1103
    by (auto dest: r_into_rtrancl intro: rtrancl_trans)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1104
qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1105
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1106
lemma member_in_class_relation:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1107
  "G\<turnstile>m member_in C \<Longrightarrow> G\<turnstile>C \<preceq>\<^sub>C declclass m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1108
by (auto dest: member_inD member_of_class_relation
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1109
        intro: rtrancl_trans)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1110
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1111
lemma member_of_Package: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1112
 "\<lbrakk>G\<turnstile>m member_of C; accmodi m = Package\<rbrakk> 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1113
  \<Longrightarrow> pid (declclass m) = pid C" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1114
proof -
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1115
  assume   member: "G\<turnstile>m member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1116
  then show " accmodi m = Package \<Longrightarrow> ?thesis" (is "PROP ?P m C")
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1117
  proof (induct rule: members.induct)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1118
    fix C m
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1119
    assume     C: "declclass m = C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1120
    then show "pid (declclass m) = pid C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1121
      by simp
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1122
  next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1123
    fix C S m  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1124
    assume inheritable: "G \<turnstile> m inheritable_in pid C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1125
    assume         hyp: "PROP ?P m S" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1126
           package_acc: "accmodi m = Package" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1127
    with inheritable package_acc hyp
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1128
    show "pid (declclass m) = pid C" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1129
      by (auto simp add: inheritable_in_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1130
  qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1131
qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1132
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1133
lemma dyn_accessible_from_commonD: "G\<turnstile>m in C dyn_accessible_from S
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1134
 \<Longrightarrow> G\<turnstile>m member_in C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1135
by (auto elim: dyn_accessible_fromR.induct)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1136
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1137
(* ### Gilt nicht für wf_progs!dynmaisches Override, 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1138
  da die accmodi Bedingung nur für stat override gilt! *)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1139
(*
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1140
lemma override_Package:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1141
 "\<lbrakk>G\<turnstile>new overrides old; 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1142
  \<And> new old. G\<turnstile>new overrides old \<Longrightarrow> accmodi old \<le> accmodi new;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1143
  accmodi old = Package; accmodi new = Package\<rbrakk>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1144
  \<Longrightarrow> pid (declclass old) = pid (declclass new)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1145
proof - 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1146
  assume wf: "\<And> new old. G\<turnstile>new overrides old \<Longrightarrow> accmodi old \<le> accmodi new"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1147
  assume ovverride: "G\<turnstile>new overrides old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1148
  then show "\<lbrakk>accmodi old = Package;accmodi new = Package\<rbrakk> \<Longrightarrow> ?thesis"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1149
    (is "?Pack old \<Longrightarrow> ?Pack new \<Longrightarrow> ?EqPid old new")
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1150
  proof (induct rule: overridesR.induct)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1151
    case Direct
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1152
    fix new old
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1153
    assume "accmodi old = Package"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1154
           "G \<turnstile> methdMembr old inheritable_in pid (declclass new)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1155
    then show "pid (declclass old) =  pid (declclass new)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1156
      by (auto simp add: inheritable_in_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1157
  next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1158
    case (Indirect inter new old)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1159
    assume accmodi_old: "accmodi old = Package" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1160
           accmodi_new: "accmodi new = Package" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1161
    assume "G \<turnstile> new overrides inter"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1162
    with wf have le_inter_new: "accmodi inter \<le> accmodi new"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1163
      by blast
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1164
    assume "G \<turnstile> inter overrides old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1165
    with wf have le_old_inter: "accmodi old \<le> accmodi inter"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1166
      by blast
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1167
    from accmodi_old accmodi_new le_inter_new le_old_inter
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1168
    have "accmodi inter = Package"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1169
      by(auto simp add: le_acc_def less_acc_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1170
    with Indirect accmodi_old accmodi_new
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1171
    show "?EqPid old new"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1172
      by auto
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1173
  qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1174
qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1175
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1176
lemma stat_override_Package:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1177
 "\<lbrakk>G\<turnstile>new overrides\<^sub>S old; 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1178
  \<And> new old. G\<turnstile>new overrides\<^sub>S old \<Longrightarrow> accmodi old \<le> accmodi new;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1179
  accmodi old = Package; accmodi new = Package\<rbrakk>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1180
  \<Longrightarrow> pid (declclass old) = pid (declclass new)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1181
proof - 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1182
  assume wf: "\<And> new old. G\<turnstile>new overrides\<^sub>S old \<Longrightarrow> accmodi old \<le> accmodi new"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1183
  assume ovverride: "G\<turnstile>new overrides\<^sub>S old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1184
  then show "\<lbrakk>accmodi old = Package;accmodi new = Package\<rbrakk> \<Longrightarrow> ?thesis"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1185
    (is "?Pack old \<Longrightarrow> ?Pack new \<Longrightarrow> ?EqPid old new")
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1186
  proof (induct rule: stat_overridesR.induct)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1187
    case Direct
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1188
    fix new old
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1189
    assume "accmodi old = Package"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1190
           "G \<turnstile> methdMembr old inheritable_in pid (declclass new)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1191
    then show "pid (declclass old) =  pid (declclass new)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1192
      by (auto simp add: inheritable_in_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1193
  next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1194
    case (Indirect inter new old)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1195
    assume accmodi_old: "accmodi old = Package" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1196
           accmodi_new: "accmodi new = Package" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1197
    assume "G \<turnstile> new overrides\<^sub>S inter"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1198
    with wf have le_inter_new: "accmodi inter \<le> accmodi new"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1199
      by blast
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1200
    assume "G \<turnstile> inter overrides\<^sub>S old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1201
    with wf have le_old_inter: "accmodi old \<le> accmodi inter"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1202
      by blast
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1203
    from accmodi_old accmodi_new le_inter_new le_old_inter
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1204
    have "accmodi inter = Package"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1205
      by(auto simp add: le_acc_def less_acc_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1206
    with Indirect accmodi_old accmodi_new
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1207
    show "?EqPid old new"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1208
      by auto
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1209
  qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1210
qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1211
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1212
*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1213
lemma no_Private_stat_override: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1214
 "\<lbrakk>G\<turnstile>new overrides\<^sub>S old\<rbrakk> \<Longrightarrow> accmodi old \<noteq> Private"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1215
by (induct set:  stat_overridesR) (auto simp add: inheritable_in_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1216
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1217
lemma no_Private_override: "\<lbrakk>G\<turnstile>new overrides old\<rbrakk> \<Longrightarrow> accmodi old \<noteq> Private"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1218
by (induct set: overridesR) (auto simp add: inheritable_in_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1219
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1220
lemma permits_acc_inheritance:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1221
 "\<lbrakk>G\<turnstile>m in statC permits_acc_to accC; G\<turnstile>dynC \<preceq>\<^sub>C statC
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1222
  \<rbrakk> \<Longrightarrow> G\<turnstile>m in dynC permits_acc_to accC"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1223
by (cases "accmodi m")
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1224
   (auto simp add: permits_acc_def
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1225
            intro: subclseq_trans) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1226
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1227
lemma field_accessible_fromD:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1228
 "\<lbrakk>G\<turnstile>membr of C accessible_from accC;is_field membr\<rbrakk> 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1229
  \<Longrightarrow> G\<turnstile>membr member_of C \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1230
      G\<turnstile>(Class C) accessible_in (pid accC) \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1231
      G\<turnstile>membr in C permits_acc_to accC"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1232
by (cases set: accessible_fromR)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1233
   (auto simp add: is_field_def split: memberdecl.splits) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1234
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1235
lemma field_accessible_from_permits_acc_inheritance:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1236
"\<lbrakk>G\<turnstile>membr of statC accessible_from accC; is_field membr; G \<turnstile> dynC \<preceq>\<^sub>C statC\<rbrakk>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1237
\<Longrightarrow> G\<turnstile>membr in dynC permits_acc_to accC"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1238
by (auto dest: field_accessible_fromD intro: permits_acc_inheritance)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1239
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1240
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1241
(*
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1242
lemma accessible_Package:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1243
 "\<lbrakk>G \<turnstile> m of C accessible_from S;accmodi m = Package;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1244
   \<And> new old. G\<turnstile>new overrides\<^sub>S old \<Longrightarrow> accmodi old \<le> accmodi new\<rbrakk>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1245
  \<Longrightarrow> pid S = pid C \<and> pid C = pid (declclass m)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1246
proof -
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1247
  assume wf: "\<And> new old. G\<turnstile>new overrides\<^sub>S old \<Longrightarrow> accmodi old \<le> accmodi new"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1248
  assume "G \<turnstile> m of C accessible_from S"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1249
  then show "accmodi m = Package \<Longrightarrow> pid S = pid C \<and> pid C = pid (declclass m)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1250
    (is "?Pack m \<Longrightarrow> ?P C m")
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1251
  proof (induct rule: accessible_fromR.induct)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1252
    fix C m
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1253
    assume "G\<turnstile>m member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1254
           "G \<turnstile> m in C permits_acc_to S"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1255
           "accmodi m = Package"      
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1256
    then show "?P C m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1257
      by (auto dest: member_of_Package simp add: permits_acc_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1258
  next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1259
    fix declC C new newm old Sup
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1260
    assume member_new: "G \<turnstile> new member_of C" and 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1261
                acc_C: "G \<turnstile> Class C accessible_in pid S" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1262
                  new: "new = (declC, mdecl newm)" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1263
             override: "G \<turnstile> (declC, newm) overrides\<^sub>S old" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1264
         subcls_C_Sup: "G\<turnstile>C \<prec>\<^sub>C Sup" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1265
              acc_old: "G \<turnstile> methdMembr old of Sup accessible_from S" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1266
                  hyp: "?Pack (methdMembr old) \<Longrightarrow> ?P Sup (methdMembr old)" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1267
          accmodi_new: "accmodi new = Package"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1268
    from override wf 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1269
    have accmodi_weaken: "accmodi old \<le> accmodi newm"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1270
      by (cases old,cases newm) auto
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1271
    from override new
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1272
    have "accmodi old \<noteq> Private"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1273
      by (simp add: no_Private_stat_override)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1274
    with accmodi_weaken accmodi_new new
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1275
    have accmodi_old: "accmodi old = Package"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1276
      by (cases "accmodi old") (auto simp add: le_acc_def less_acc_def) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1277
    with hyp 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1278
    have P_sup: "?P Sup (methdMembr old)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1279
      by (simp)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1280
    from wf override new accmodi_old accmodi_new
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1281
    have eq_pid_new_old: "pid (declclass new) = pid (declclass old)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1282
      by (auto dest: stat_override_Package) 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1283
    from member_new accmodi_new
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1284
    have "pid (declclass new) = pid C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1285
      by (auto dest: member_of_Package)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1286
    with eq_pid_new_old P_sup show "?P C new"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1287
      by auto
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1288
  qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1289
qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1290
*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1291
lemma accessible_fieldD: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1292
 "\<lbrakk>G\<turnstile>membr of C accessible_from accC; is_field membr\<rbrakk>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1293
 \<Longrightarrow> G\<turnstile>membr member_of C \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1294
     G\<turnstile>(Class C) accessible_in (pid accC) \<and>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1295
     G\<turnstile>membr in C permits_acc_to accC"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1296
by (induct rule: accessible_fromR.induct) (auto dest: is_fieldD)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1297
      
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1298
(* lemmata:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1299
 Wegen  G\<turnstile>Super accessible_in (pid C) folgt:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1300
  G\<turnstile>m declared_in C; G\<turnstile>m member_of D; accmodi m = Package (G\<turnstile>D \<preceq>\<^sub>C C)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1301
  \<Longrightarrow> pid C = pid D 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1302
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1303
  C package
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1304
  m public in C
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1305
  für alle anderen D: G\<turnstile>m undeclared_in C
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1306
  m wird in alle subklassen vererbt, auch aus dem Package heraus!
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1307
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1308
  G\<turnstile>m member_of C \<Longrightarrow> \<exists> D. G\<turnstile>C \<preceq>\<^sub>C D \<and> G\<turnstile>m declared_in D
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1309
*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1310
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1311
(* Begriff (C,m) overrides (D,m)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1312
    3 Fälle: Direkt,
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1313
             Indirekt über eine Zwischenklasse (ohne weiteres override)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1314
             Indirekt über override
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1315
*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1316
   
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1317
(*
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1318
"G\<turnstile>m member_of C \<equiv> 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1319
constdefs declares_method:: "prog \<Rightarrow> sig \<Rightarrow> qtname \<Rightarrow> methd \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1320
                                 ("_,_\<turnstile> _ declares'_method _" [61,61,61,61] 60)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1321
"G,sig\<turnstile>C declares_method m \<equiv> cdeclaredmethd G C sig = Some m" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1322
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1323
constdefs is_declared:: "prog \<Rightarrow> sig \<Rightarrow> (qtname \<times> methd) \<Rightarrow> bool"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1324
"is_declared G sig em \<equiv> G,sig\<turnstile>declclass em declares_method mthd em"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1325
*)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1326
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1327
lemma member_of_Private:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1328
"\<lbrakk>G\<turnstile>m member_of C; accmodi m = Private\<rbrakk> \<Longrightarrow> declclass m = C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1329
by (induct set: members) (auto simp add: inheritable_in_def)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1330
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1331
lemma member_of_subclseq_declC:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1332
  "G\<turnstile>m member_of C \<Longrightarrow> G\<turnstile>C \<preceq>\<^sub>C declclass m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1333
by (induct set: members) (auto dest: r_into_rtrancl intro: rtrancl_trans)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1334
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1335
lemma member_of_inheritance:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1336
  (assumes    m: "G\<turnstile>m member_of D" and 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1337
     subclseq_D_C: "G\<turnstile>D \<preceq>\<^sub>C C" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1338
     subclseq_C_m: "G\<turnstile>C \<preceq>\<^sub>C declclass m" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1339
               ws: "ws_prog G" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1340
  ) "G\<turnstile>m member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1341
proof -
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1342
  from m subclseq_D_C subclseq_C_m
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1343
  show ?thesis
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1344
  proof (induct)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1345
    case (Immediate D m)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1346
    assume "declclass m = D" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1347
           "G\<turnstile>D\<preceq>\<^sub>C C" and "G\<turnstile>C\<preceq>\<^sub>C declclass m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1348
    with ws have "D=C" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1349
      by (auto intro: subclseq_acyclic)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1350
    with Immediate 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1351
    show "G\<turnstile>m member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1352
      by (auto intro: members.Immediate)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1353
  next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1354
    case (Inherited D S m)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1355
    assume member_of_D_props: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1356
            "G \<turnstile> m inheritable_in pid D" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1357
            "G\<turnstile> memberid m undeclared_in D"  
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1358
            "G \<turnstile> Class S accessible_in pid D" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1359
            "G \<turnstile> m member_of S"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1360
    assume super: "G\<turnstile>D\<prec>\<^sub>C\<^sub>1S"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1361
    assume hyp: "\<lbrakk>G\<turnstile>S\<preceq>\<^sub>C C; G\<turnstile>C\<preceq>\<^sub>C declclass m\<rbrakk> \<Longrightarrow> G \<turnstile> m member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1362
    assume subclseq_C_m: "G\<turnstile>C\<preceq>\<^sub>C declclass m"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1363
    assume "G\<turnstile>D\<preceq>\<^sub>C C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1364
    then show "G\<turnstile>m member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1365
    proof (cases rule: subclseq_cases)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1366
      case Eq
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1367
      assume "D=C" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1368
      with super member_of_D_props 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1369
      show ?thesis
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1370
	by (auto intro: members.Inherited)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1371
    next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1372
      case Subcls
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1373
      assume "G\<turnstile>D\<prec>\<^sub>C C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1374
      with super 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1375
      have "G\<turnstile>S\<preceq>\<^sub>C C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1376
	by (auto dest: subcls1D subcls_superD)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1377
      with subclseq_C_m hyp show ?thesis
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1378
	by blast
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1379
    qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1380
  qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1381
qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1382
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1383
lemma member_of_subcls:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1384
  (assumes    old: "G\<turnstile>old member_of C" and 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1385
              new: "G\<turnstile>new member_of D" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1386
             eqid: "memberid new = memberid old" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1387
     subclseq_D_C: "G\<turnstile>D \<preceq>\<^sub>C C" and 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1388
   subcls_new_old: "G\<turnstile>declclass new \<prec>\<^sub>C declclass old" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1389
               ws: "ws_prog G"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1390
  ) "G\<turnstile>D \<prec>\<^sub>C C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1391
proof -
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1392
  from old 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1393
  have subclseq_C_old: "G\<turnstile>C \<preceq>\<^sub>C declclass old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1394
    by (auto dest: member_of_subclseq_declC)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1395
  from new 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1396
  have subclseq_D_new: "G\<turnstile>D \<preceq>\<^sub>C declclass new"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1397
    by (auto dest: member_of_subclseq_declC)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1398
  from subcls_new_old ws
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1399
  have neq_new_old: "new\<noteq>old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1400
    by (cases new,cases old) (auto dest: subcls_irrefl)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1401
  from subclseq_D_new subclseq_D_C
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1402
  have "G\<turnstile>(declclass new) \<preceq>\<^sub>C C \<or> G\<turnstile>C \<preceq>\<^sub>C (declclass new)" 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1403
    by (rule subcls_compareable)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1404
  then have "G\<turnstile>(declclass new) \<preceq>\<^sub>C C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1405
  proof
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1406
    assume "G\<turnstile>declclass new\<preceq>\<^sub>C C" then show ?thesis .
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1407
  next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1408
    assume "G\<turnstile>C \<preceq>\<^sub>C (declclass new)"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1409
    with new subclseq_D_C ws 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1410
    have "G\<turnstile>new member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1411
      by (blast intro: member_of_inheritance)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1412
    with eqid old 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1413
    have "new=old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1414
      by (blast intro: unique_member_of)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1415
    with neq_new_old 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1416
    show ?thesis
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1417
      by contradiction
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1418
  qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1419
  then show ?thesis
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1420
  proof (cases rule: subclseq_cases)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1421
    case Eq
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1422
    assume "declclass new = C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1423
    with new have "G\<turnstile>new member_of C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1424
      by (auto dest: member_of_member_of_declC)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1425
    with eqid old 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1426
    have "new=old"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1427
      by (blast intro: unique_member_of)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1428
    with neq_new_old 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1429
    show ?thesis
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1430
      by contradiction
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1431
  next
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1432
    case Subcls
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1433
    assume "G\<turnstile>declclass new\<prec>\<^sub>C C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1434
    with subclseq_D_new
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1435
    show "G\<turnstile>D\<prec>\<^sub>C C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1436
      by (rule rtrancl_trancl_trancl)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1437
  qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1438
qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1439
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1440
corollary member_of_overrides_subcls:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1441
 "\<lbrakk>G\<turnstile>Methd sig old member_of C; G\<turnstile>Methd sig new member_of D;G\<turnstile>D \<preceq>\<^sub>C C;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1442
   G,sig\<turnstile>new overrides old; ws_prog G\<rbrakk>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1443
 \<Longrightarrow> G\<turnstile>D \<prec>\<^sub>C C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1444
by (drule overrides_commonD) (auto intro: member_of_subcls)    
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1445
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1446
corollary member_of_stat_overrides_subcls:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1447
 "\<lbrakk>G\<turnstile>Methd sig old member_of C; G\<turnstile>Methd sig new member_of D;G\<turnstile>D \<preceq>\<^sub>C C;
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1448
   G,sig\<turnstile>new overrides\<^sub>S old; ws_prog G\<rbrakk>
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1449
 \<Longrightarrow> G\<turnstile>D \<prec>\<^sub>C C"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1450
by (drule stat_overrides_commonD) (auto intro: member_of_subcls)    
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1451
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1452
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1453
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1454
lemma inherited_field_access: 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1455
 (assumes stat_acc: "G\<turnstile>membr of statC accessible_from accC" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1456
          is_field: "is_field membr" and 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1457
          subclseq: "G \<turnstile> dynC \<preceq>\<^sub>C statC"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1458
 ) "G\<turnstile>membr in dynC dyn_accessible_from accC"
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1459
proof -
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1460
  from stat_acc is_field subclseq 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1461
  show ?thesis
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1462
    by (auto dest: accessible_fieldD 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1463
            intro: dyn_accessible_fromR.immediate 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1464
                   member_inI 
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1465
                   permits_acc_inheritance)
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1466
qed
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1467
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1468
lemma accessible_inheritance:
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1469
 (assumes stat_acc: "G\<turnstile>m of statC accessible_from accC" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1470
          subclseq: "G\<turnstile>dynC \<preceq>\<^sub>C statC" and
00d4a435777f Isabelle/Bali sources;
schirmer
parents:
diff changeset
  1471
       member_dynC: "G\<turnstile>m member_of dynC" and