| author | haftmann | 
| Thu, 18 Nov 2010 17:06:02 +0100 | |
| changeset 40611 | 9eb0a9dd186e | 
| parent 36319 | 8feb2c4bef1a | 
| child 45605 | a89b4bc311a5 | 
| permissions | -rw-r--r-- | 
| 12517 | 1  | 
(* Title: HOL/MicroJava/J/Example.thy  | 
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
2  | 
Author: David von Oheimb  | 
| 11372 | 3  | 
Copyright 1999 Technische Universitaet Muenchen  | 
| 11070 | 4  | 
*)  | 
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
5  | 
|
| 12911 | 6  | 
header {* \isaheader{Example MicroJava Program} *}
 | 
| 11070 | 7  | 
|
| 16417 | 8  | 
theory Example imports SystemClasses Eval begin  | 
| 11070 | 9  | 
|
10  | 
text {* 
 | 
|
11  | 
The following example MicroJava program includes:  | 
|
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
12  | 
class declarations with inheritance, hiding of fields, and overriding of  | 
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
13  | 
methods (with refined result type),  | 
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
14  | 
instance creation, local assignment, sequential composition,  | 
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
15  | 
method call with dynamic binding, literal values,  | 
| 11070 | 16  | 
expression statement, local access, type cast, field assignment (in part),  | 
17  | 
skip.  | 
|
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
18  | 
|
| 11070 | 19  | 
\begin{verbatim}
 | 
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
20  | 
class Base {
 | 
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
21  | 
boolean vee;  | 
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
22  | 
  Base foo(Base x) {return x;}
 | 
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
23  | 
}  | 
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
24  | 
|
| 10229 | 25  | 
class Ext extends Base {
 | 
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
26  | 
int vee;  | 
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
27  | 
  Ext foo(Base x) {((Ext)x).vee=1; return null;}
 | 
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
28  | 
}  | 
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
29  | 
|
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
30  | 
class Example {
 | 
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
31  | 
  public static void main (String args[]) {
 | 
| 9498 | 32  | 
Base e=new Ext();  | 
33  | 
e.foo(null);  | 
|
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
34  | 
}  | 
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
35  | 
}  | 
| 11070 | 36  | 
\end{verbatim}
 | 
37  | 
*}  | 
|
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
38  | 
|
| 24783 | 39  | 
datatype cnam' = Base' | Ext'  | 
40  | 
datatype vnam' = vee' | x' | e'  | 
|
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
41  | 
|
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
42  | 
consts  | 
| 24783 | 43  | 
cnam' :: "cnam' => cname"  | 
44  | 
vnam' :: "vnam' => vnam"  | 
|
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
45  | 
|
| 24783 | 46  | 
-- "@{text cnam'} and @{text vnam'} are intended to be isomorphic 
 | 
| 12517 | 47  | 
    to @{text cnam} and @{text vnam}"
 | 
48  | 
axioms  | 
|
| 24783 | 49  | 
inj_cnam': "(cnam' x = cnam' y) = (x = y)"  | 
50  | 
inj_vnam': "(vnam' x = vnam' y) = (x = y)"  | 
|
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
51  | 
|
| 24783 | 52  | 
surj_cnam': "\<exists>m. n = cnam' m"  | 
53  | 
surj_vnam': "\<exists>m. n = vnam' m"  | 
|
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
54  | 
|
| 24783 | 55  | 
declare inj_cnam' [simp] inj_vnam' [simp]  | 
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
56  | 
|
| 35102 | 57  | 
abbreviation Base :: cname  | 
58  | 
where "Base == cnam' Base'"  | 
|
59  | 
abbreviation Ext :: cname  | 
|
60  | 
where "Ext == cnam' Ext'"  | 
|
61  | 
abbreviation vee :: vname  | 
|
62  | 
where "vee == VName (vnam' vee')"  | 
|
63  | 
abbreviation x :: vname  | 
|
64  | 
where "x == VName (vnam' x')"  | 
|
65  | 
abbreviation e :: vname  | 
|
66  | 
where "e == VName (vnam' e')"  | 
|
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
67  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
68  | 
axioms  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
69  | 
Base_not_Object: "Base \<noteq> Object"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
70  | 
Ext_not_Object: "Ext \<noteq> Object"  | 
| 12951 | 71  | 
Base_not_Xcpt: "Base \<noteq> Xcpt z"  | 
72  | 
Ext_not_Xcpt: "Ext \<noteq> Xcpt z"  | 
|
73  | 
e_not_This: "e \<noteq> This"  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
74  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
75  | 
declare Base_not_Object [simp] Ext_not_Object [simp]  | 
| 12951 | 76  | 
declare Base_not_Xcpt [simp] Ext_not_Xcpt [simp]  | 
| 
11643
 
0b3a02daf7fb
Added axiom e~=This to reflect strengthened precond. in rule LAss
 
streckem 
parents: 
11372 
diff
changeset
 | 
77  | 
declare e_not_This [simp]  | 
| 12951 | 78  | 
declare Base_not_Object [symmetric, simp]  | 
79  | 
declare Ext_not_Object [symmetric, simp]  | 
|
80  | 
declare Base_not_Xcpt [symmetric, simp]  | 
|
81  | 
declare Ext_not_Xcpt [symmetric, simp]  | 
|
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
82  | 
|
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
83  | 
consts  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
84  | 
foo_Base:: java_mb  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
85  | 
foo_Ext :: java_mb  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
86  | 
BaseC :: "java_mb cdecl"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
87  | 
ExtC :: "java_mb cdecl"  | 
| 12517 | 88  | 
test :: stmt  | 
89  | 
foo :: mname  | 
|
90  | 
a :: loc  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
91  | 
b :: loc  | 
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
92  | 
|
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
93  | 
defs  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
94  | 
foo_Base_def:"foo_Base == ([x],[],Skip,LAcc x)"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
95  | 
BaseC_def:"BaseC == (Base, (Object,  | 
| 12517 | 96  | 
[(vee, PrimT Boolean)],  | 
97  | 
[((foo,[Class Base]),Class Base,foo_Base)]))"  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
98  | 
  foo_Ext_def:"foo_Ext == ([x],[],Expr( {Ext}Cast Ext
 | 
| 12517 | 99  | 
(LAcc x)..vee:=Lit (Intg Numeral1)),  | 
100  | 
Lit Null)"  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
101  | 
ExtC_def: "ExtC == (Ext, (Base ,  | 
| 12517 | 102  | 
[(vee, PrimT Integer)],  | 
103  | 
[((foo,[Class Base]),Class Ext,foo_Ext)]))"  | 
|
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
104  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
105  | 
test_def:"test == Expr(e::=NewC Ext);;  | 
| 10763 | 106  | 
                    Expr({Base}LAcc e..foo({[Class Base]}[Lit Null]))"
 | 
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
107  | 
|
| 
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
108  | 
|
| 20768 | 109  | 
abbreviation  | 
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
20768 
diff
changeset
 | 
110  | 
NP :: xcpt where  | 
| 20768 | 111  | 
"NP == NullPointer"  | 
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
112  | 
|
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
20768 
diff
changeset
 | 
113  | 
abbreviation  | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
20768 
diff
changeset
 | 
114  | 
tprg ::"java_mb prog" where  | 
| 20768 | 115  | 
"tprg == [ObjectC, BaseC, ExtC, ClassCastC, NullPointerC, OutOfMemoryC]"  | 
116  | 
||
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
20768 
diff
changeset
 | 
117  | 
abbreviation  | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
20768 
diff
changeset
 | 
118  | 
obj1 :: obj where  | 
| 20768 | 119  | 
"obj1 == (Ext, empty((vee, Base)\<mapsto>Bool False) ((vee, Ext )\<mapsto>Intg 0))"  | 
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
120  | 
|
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
20768 
diff
changeset
 | 
121  | 
abbreviation "s0 == Norm (empty, empty)"  | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
20768 
diff
changeset
 | 
122  | 
abbreviation "s1 == Norm (empty(a\<mapsto>obj1),empty(e\<mapsto>Addr a))"  | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
20768 
diff
changeset
 | 
123  | 
abbreviation "s2 == Norm (empty(a\<mapsto>obj1),empty(x\<mapsto>Null)(This\<mapsto>Addr a))"  | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
20768 
diff
changeset
 | 
124  | 
abbreviation "s3 == (Some NP, empty(a\<mapsto>obj1),empty(e\<mapsto>Addr a))"  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
125  | 
|
| 24074 | 126  | 
lemmas map_of_Cons = map_of.simps(2)  | 
127  | 
||
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
128  | 
lemma map_of_Cons1 [simp]: "map_of ((aa,bb)#ps) aa = Some bb"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
129  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
130  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
131  | 
lemma map_of_Cons2 [simp]: "aa\<noteq>k ==> map_of ((k,bb)#ps) aa = map_of ps aa"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
132  | 
apply (simp (no_asm_simp))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
133  | 
done  | 
| 12517 | 134  | 
declare map_of_Cons [simp del] -- "sic!"  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
135  | 
|
| 28524 | 136  | 
lemma class_tprg_Object [simp]: "class tprg Object = Some (undefined, [], [])"  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
137  | 
apply (unfold ObjectC_def class_def)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
138  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
139  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
140  | 
|
| 12951 | 141  | 
lemma class_tprg_NP [simp]: "class tprg (Xcpt NP) = Some (Object, [], [])"  | 
142  | 
apply (unfold ObjectC_def NullPointerC_def ClassCastC_def OutOfMemoryC_def BaseC_def ExtC_def class_def)  | 
|
143  | 
apply (simp (no_asm))  | 
|
144  | 
done  | 
|
145  | 
||
146  | 
lemma class_tprg_OM [simp]: "class tprg (Xcpt OutOfMemory) = Some (Object, [], [])"  | 
|
147  | 
apply (unfold ObjectC_def NullPointerC_def ClassCastC_def OutOfMemoryC_def BaseC_def ExtC_def class_def)  | 
|
148  | 
apply (simp (no_asm))  | 
|
149  | 
done  | 
|
150  | 
||
151  | 
lemma class_tprg_CC [simp]: "class tprg (Xcpt ClassCast) = Some (Object, [], [])"  | 
|
152  | 
apply (unfold ObjectC_def NullPointerC_def ClassCastC_def OutOfMemoryC_def BaseC_def ExtC_def class_def)  | 
|
153  | 
apply (simp (no_asm))  | 
|
154  | 
done  | 
|
155  | 
||
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
156  | 
lemma class_tprg_Base [simp]:  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
157  | 
"class tprg Base = Some (Object,  | 
| 12517 | 158  | 
[(vee, PrimT Boolean)],  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
159  | 
[((foo, [Class Base]), Class Base, foo_Base)])"  | 
| 12951 | 160  | 
apply (unfold ObjectC_def NullPointerC_def ClassCastC_def OutOfMemoryC_def BaseC_def ExtC_def class_def)  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
161  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
162  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
163  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
164  | 
lemma class_tprg_Ext [simp]:  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
165  | 
"class tprg Ext = Some (Base,  | 
| 12517 | 166  | 
[(vee, PrimT Integer)],  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
167  | 
[((foo, [Class Base]), Class Ext, foo_Ext)])"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
168  | 
apply (unfold ObjectC_def BaseC_def ExtC_def class_def)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
169  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
170  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
171  | 
|
| 
33954
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
172  | 
lemma not_Object_subcls [elim!]: "(Object, C) \<in> (subcls1 tprg)^+ ==> R"  | 
| 
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
173  | 
apply (auto dest!: tranclD subcls1D)  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
174  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
175  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
176  | 
lemma subcls_ObjectD [dest!]: "tprg\<turnstile>Object\<preceq>C C ==> C = Object"  | 
| 
33954
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
177  | 
apply (erule rtrancl_induct)  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
178  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
179  | 
apply (drule subcls1D)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
180  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
181  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
182  | 
|
| 
33954
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
183  | 
lemma not_Base_subcls_Ext [elim!]: "(Base, Ext) \<in> (subcls1 tprg)^+ ==> R"  | 
| 
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
184  | 
apply (auto dest!: tranclD subcls1D)  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
185  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
186  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
187  | 
lemma class_tprgD:  | 
| 12951 | 188  | 
"class tprg C = Some z ==> C=Object \<or> C=Base \<or> C=Ext \<or> C=Xcpt NP \<or> C=Xcpt ClassCast \<or> C=Xcpt OutOfMemory"  | 
189  | 
apply (unfold ObjectC_def ClassCastC_def NullPointerC_def OutOfMemoryC_def BaseC_def ExtC_def class_def)  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
190  | 
apply (auto split add: split_if_asm simp add: map_of_Cons)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
191  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
192  | 
|
| 
33954
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
193  | 
lemma not_class_subcls_class [elim!]: "(C, C) \<in> (subcls1 tprg)^+ ==> R"  | 
| 
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
194  | 
apply (auto dest!: tranclD subcls1D)  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
195  | 
apply (frule class_tprgD)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
196  | 
apply (auto dest!:)  | 
| 
33954
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
197  | 
apply (drule rtranclD)  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
198  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
199  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
200  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
201  | 
lemma unique_classes: "unique tprg"  | 
| 12951 | 202  | 
apply (simp (no_asm) add: ObjectC_def BaseC_def ExtC_def NullPointerC_def ClassCastC_def OutOfMemoryC_def)  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
203  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
204  | 
|
| 
33954
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
205  | 
lemmas subcls_direct = subcls1I [THEN r_into_rtrancl [where r="subcls1 G"], standard]  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
206  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
207  | 
lemma Ext_subcls_Base [simp]: "tprg\<turnstile>Ext\<preceq>C Base"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
208  | 
apply (rule subcls_direct)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
209  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
210  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
211  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
212  | 
lemma Ext_widen_Base [simp]: "tprg\<turnstile>Class Ext\<preceq> Class Base"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
213  | 
apply (rule widen.subcls)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
214  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
215  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
216  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
217  | 
declare ty_expr_ty_exprs_wt_stmt.intros [intro!]  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
218  | 
|
| 
33954
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
219  | 
lemma acyclic_subcls1': "acyclic (subcls1 tprg)"  | 
| 
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
220  | 
apply (rule acyclicI)  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
221  | 
apply safe  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
222  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
223  | 
|
| 
33954
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
224  | 
lemmas wf_subcls1' = acyclic_subcls1' [THEN finite_subcls1 [THEN finite_acyclic_wf_converse]]  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
225  | 
|
| 24783 | 226  | 
lemmas fields_rec' = wf_subcls1' [THEN [2] fields_rec_lemma]  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
227  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
228  | 
lemma fields_Object [simp]: "fields (tprg, Object) = []"  | 
| 24783 | 229  | 
apply (subst fields_rec')  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
230  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
231  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
232  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
233  | 
declare is_class_def [simp]  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
234  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
235  | 
lemma fields_Base [simp]: "fields (tprg,Base) = [((vee, Base), PrimT Boolean)]"  | 
| 24783 | 236  | 
apply (subst fields_rec')  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
237  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
238  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
239  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
240  | 
lemma fields_Ext [simp]:  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
241  | 
"fields (tprg, Ext) = [((vee, Ext ), PrimT Integer)] @ fields (tprg, Base)"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
242  | 
apply (rule trans)  | 
| 24783 | 243  | 
apply (rule fields_rec')  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
244  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
245  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
246  | 
|
| 24783 | 247  | 
lemmas method_rec' = wf_subcls1' [THEN [2] method_rec_lemma]  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
248  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
249  | 
lemma method_Object [simp]: "method (tprg,Object) = map_of []"  | 
| 24783 | 250  | 
apply (subst method_rec')  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
251  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
252  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
253  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
254  | 
lemma method_Base [simp]: "method (tprg, Base) = map_of  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
255  | 
[((foo, [Class Base]), Base, (Class Base, foo_Base))]"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
256  | 
apply (rule trans)  | 
| 24783 | 257  | 
apply (rule method_rec')  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
258  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
259  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
260  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
261  | 
lemma method_Ext [simp]: "method (tprg, Ext) = (method (tprg, Base) ++ map_of  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
262  | 
[((foo, [Class Base]), Ext , (Class Ext, foo_Ext))])"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
263  | 
apply (rule trans)  | 
| 24783 | 264  | 
apply (rule method_rec')  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
265  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
266  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
267  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
268  | 
lemma wf_foo_Base:  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
269  | 
"wf_mdecl wf_java_mdecl tprg Base ((foo, [Class Base]), (Class Base, foo_Base))"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
270  | 
apply (unfold wf_mdecl_def wf_mhead_def wf_java_mdecl_def foo_Base_def)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
271  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
272  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
273  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
274  | 
lemma wf_foo_Ext:  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
275  | 
"wf_mdecl wf_java_mdecl tprg Ext ((foo, [Class Base]), (Class Ext, foo_Ext))"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
276  | 
apply (unfold wf_mdecl_def wf_mhead_def wf_java_mdecl_def foo_Ext_def)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
277  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
278  | 
apply (rule ty_expr_ty_exprs_wt_stmt.Cast)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
279  | 
prefer 2  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
280  | 
apply (simp)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
281  | 
apply (rule_tac [2] cast.subcls)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
282  | 
apply (unfold field_def)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
283  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
284  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
285  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
286  | 
lemma wf_ObjectC:  | 
| 14045 | 287  | 
"ws_cdecl tprg ObjectC \<and>  | 
288  | 
wf_cdecl_mdecl wf_java_mdecl tprg ObjectC \<and> wf_mrT tprg ObjectC"  | 
|
289  | 
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def  | 
|
290  | 
wf_mrT_def wf_fdecl_def ObjectC_def)  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
291  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
292  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
293  | 
|
| 12951 | 294  | 
lemma wf_NP:  | 
| 14045 | 295  | 
"ws_cdecl tprg NullPointerC \<and>  | 
296  | 
wf_cdecl_mdecl wf_java_mdecl tprg NullPointerC \<and> wf_mrT tprg NullPointerC"  | 
|
297  | 
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def  | 
|
298  | 
wf_mrT_def wf_fdecl_def NullPointerC_def)  | 
|
| 12951 | 299  | 
apply (simp add: class_def)  | 
300  | 
apply (fold NullPointerC_def class_def)  | 
|
301  | 
apply auto  | 
|
302  | 
done  | 
|
303  | 
||
304  | 
lemma wf_OM:  | 
|
| 14045 | 305  | 
"ws_cdecl tprg OutOfMemoryC \<and>  | 
306  | 
wf_cdecl_mdecl wf_java_mdecl tprg OutOfMemoryC \<and> wf_mrT tprg OutOfMemoryC"  | 
|
307  | 
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def  | 
|
308  | 
wf_mrT_def wf_fdecl_def OutOfMemoryC_def)  | 
|
| 12951 | 309  | 
apply (simp add: class_def)  | 
310  | 
apply (fold OutOfMemoryC_def class_def)  | 
|
311  | 
apply auto  | 
|
312  | 
done  | 
|
313  | 
||
314  | 
lemma wf_CC:  | 
|
| 14045 | 315  | 
"ws_cdecl tprg ClassCastC \<and>  | 
316  | 
wf_cdecl_mdecl wf_java_mdecl tprg ClassCastC \<and> wf_mrT tprg ClassCastC"  | 
|
317  | 
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def  | 
|
318  | 
wf_mrT_def wf_fdecl_def ClassCastC_def)  | 
|
| 12951 | 319  | 
apply (simp add: class_def)  | 
320  | 
apply (fold ClassCastC_def class_def)  | 
|
321  | 
apply auto  | 
|
322  | 
done  | 
|
323  | 
||
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
324  | 
lemma wf_BaseC:  | 
| 14045 | 325  | 
"ws_cdecl tprg BaseC \<and>  | 
326  | 
wf_cdecl_mdecl wf_java_mdecl tprg BaseC \<and> wf_mrT tprg BaseC"  | 
|
327  | 
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def  | 
|
328  | 
wf_mrT_def wf_fdecl_def BaseC_def)  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
329  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
330  | 
apply (fold BaseC_def)  | 
| 14045 | 331  | 
apply (rule mp) defer apply (rule wf_foo_Base)  | 
332  | 
apply (auto simp add: wf_mdecl_def)  | 
|
333  | 
done  | 
|
334  | 
||
335  | 
||
336  | 
lemma wf_ExtC:  | 
|
337  | 
"ws_cdecl tprg ExtC \<and>  | 
|
338  | 
wf_cdecl_mdecl wf_java_mdecl tprg ExtC \<and> wf_mrT tprg ExtC"  | 
|
339  | 
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def  | 
|
340  | 
wf_mrT_def wf_fdecl_def ExtC_def)  | 
|
341  | 
apply (simp (no_asm))  | 
|
342  | 
apply (fold ExtC_def)  | 
|
343  | 
apply (rule mp) defer apply (rule wf_foo_Ext)  | 
|
344  | 
apply (auto simp add: wf_mdecl_def)  | 
|
| 
33954
 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 
haftmann 
parents: 
28524 
diff
changeset
 | 
345  | 
apply (drule rtranclD)  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
346  | 
apply auto  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
347  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
348  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
349  | 
|
| 12951 | 350  | 
lemma [simp]: "fst ObjectC = Object" by (simp add: ObjectC_def)  | 
351  | 
||
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
352  | 
lemma wf_tprg:  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
353  | 
"wf_prog wf_java_mdecl tprg"  | 
| 14045 | 354  | 
apply (unfold wf_prog_def ws_prog_def Let_def)  | 
| 12951 | 355  | 
apply (simp add: wf_ObjectC wf_BaseC wf_ExtC wf_NP wf_OM wf_CC unique_classes)  | 
356  | 
apply (rule wf_syscls)  | 
|
357  | 
apply (simp add: SystemClasses_def)  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
358  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
359  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
360  | 
lemma appl_methds_foo_Base:  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
361  | 
"appl_methds tprg Base (foo, [NT]) =  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
362  | 
  {((Class Base, Class Base), [Class Base])}"
 | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
363  | 
apply (unfold appl_methds_def)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
364  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
365  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
366  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
367  | 
lemma max_spec_foo_Base: "max_spec tprg Base (foo, [NT]) =  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
368  | 
  {((Class Base, Class Base), [Class Base])}"
 | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
369  | 
apply (unfold max_spec_def)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
370  | 
apply (auto simp add: appl_methds_foo_Base)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
371  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
372  | 
|
| 
23894
 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 
wenzelm 
parents: 
23757 
diff
changeset
 | 
373  | 
ML {* val t = resolve_tac @{thms ty_expr_ty_exprs_wt_stmt.intros} 1 *}
 | 
| 36319 | 374  | 
schematic_lemma wt_test: "(tprg, empty(e\<mapsto>Class Base))\<turnstile>  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
375  | 
  Expr(e::=NewC Ext);; Expr({Base}LAcc e..foo({?pTs'}[Lit Null]))\<surd>"
 | 
| 12517 | 376  | 
apply (tactic t) -- ";;"  | 
377  | 
apply (tactic t) -- "Expr"  | 
|
378  | 
apply (tactic t) -- "LAss"  | 
|
379  | 
apply    simp -- {* @{text "e \<noteq> This"} *}
 | 
|
380  | 
apply (tactic t) -- "LAcc"  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
381  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
382  | 
apply (simp (no_asm))  | 
| 12517 | 383  | 
apply (tactic t) -- "NewC"  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
384  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
385  | 
apply (simp (no_asm))  | 
| 12517 | 386  | 
apply (tactic t) -- "Expr"  | 
387  | 
apply (tactic t) -- "Call"  | 
|
388  | 
apply (tactic t) -- "LAcc"  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
389  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
390  | 
apply (simp (no_asm))  | 
| 12517 | 391  | 
apply (tactic t) -- "Cons"  | 
392  | 
apply (tactic t) -- "Lit"  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
393  | 
apply (simp (no_asm))  | 
| 12517 | 394  | 
apply (tactic t) -- "Nil"  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
395  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
396  | 
apply (rule max_spec_foo_Base)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
397  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
398  | 
|
| 
23894
 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 
wenzelm 
parents: 
23757 
diff
changeset
 | 
399  | 
ML {* val e = resolve_tac (@{thm NewCI} :: @{thms eval_evals_exec.intros}) 1 *}
 | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
400  | 
|
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
401  | 
declare split_if [split del]  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
402  | 
declare init_vars_def [simp] c_hupd_def [simp] cast_ok_def [simp]  | 
| 36319 | 403  | 
schematic_lemma exec_test:  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
404  | 
" [|new_Addr (heap (snd s0)) = (a, None)|] ==>  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
405  | 
tprg\<turnstile>s0 -test-> ?s"  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
406  | 
apply (unfold test_def)  | 
| 12517 | 407  | 
-- "?s = s3 "  | 
408  | 
apply (tactic e) -- ";;"  | 
|
409  | 
apply (tactic e) -- "Expr"  | 
|
410  | 
apply (tactic e) -- "LAss"  | 
|
411  | 
apply (tactic e) -- "NewC"  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
412  | 
apply force  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
413  | 
apply force  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
414  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
415  | 
apply (erule thin_rl)  | 
| 12517 | 416  | 
apply (tactic e) -- "Expr"  | 
417  | 
apply (tactic e) -- "Call"  | 
|
418  | 
apply (tactic e) -- "LAcc"  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
419  | 
apply force  | 
| 12517 | 420  | 
apply (tactic e) -- "Cons"  | 
421  | 
apply (tactic e) -- "Lit"  | 
|
422  | 
apply (tactic e) -- "Nil"  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
423  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
424  | 
apply (force simp add: foo_Ext_def)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
425  | 
apply (simp (no_asm))  | 
| 12517 | 426  | 
apply (tactic e) -- "Expr"  | 
427  | 
apply (tactic e) -- "FAss"  | 
|
428  | 
apply (tactic e) -- "Cast"  | 
|
429  | 
apply (tactic e) -- "LAcc"  | 
|
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
430  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
431  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
432  | 
apply (simp (no_asm))  | 
| 12517 | 433  | 
apply (tactic e) -- "XcptE"  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
434  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
435  | 
apply (rule surjective_pairing [THEN sym, THEN[2]trans], subst Pair_eq, force)  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
436  | 
apply (simp (no_asm))  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
437  | 
apply (simp (no_asm))  | 
| 12517 | 438  | 
apply (tactic e) -- "XcptE"  | 
| 
11026
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
439  | 
done  | 
| 
 
a50365d21144
converted to Isar, simplifying recursion on class hierarchy
 
oheimb 
parents: 
10763 
diff
changeset
 | 
440  | 
|
| 
9346
 
297dcbf64526
re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
 
oheimb 
parents:  
diff
changeset
 | 
441  | 
end  |