src/HOL/MicroJava/J/Example.thy
author wenzelm
Thu, 11 Feb 2010 00:45:02 +0100
changeset 35102 cc7a0b9f938c
parent 33954 1bc3b688548c
child 36319 8feb2c4bef1a
permissions -rwxr-xr-x
modernized translations;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
     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
648795477bb5 corrected xsymbol/HTML syntax
oheimb
parents: 11070
diff changeset
     3
    Copyright   1999 Technische Universitaet Muenchen
11070
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
     4
*)
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
     5
12911
704713ca07ea new document
kleing
parents: 12517
diff changeset
     6
header {* \isaheader{Example MicroJava Program} *}
11070
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
     7
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15306
diff changeset
     8
theory Example imports SystemClasses Eval begin
11070
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
     9
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    10
text {* 
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    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
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    16
 expression statement, local access, type cast, field assignment (in part), 
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    17
 skip.
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    18
11070
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    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
10e2d29a77de cosmetics
oheimb
parents: 10042
diff changeset
    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
b5d6db4111bc minor corrections
oheimb
parents: 9348
diff changeset
    32
    Base e=new Ext();
b5d6db4111bc minor corrections
oheimb
parents: 9348
diff changeset
    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
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    36
\end{verbatim}
cc421547e744 improved document (added headers etc)
oheimb
parents: 11026
diff changeset
    37
*}
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    38
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
    39
datatype cnam' = Base' | Ext'
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
    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
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
    43
  cnam' :: "cnam' => cname"
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
    44
  vnam' :: "vnam' => vnam"
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    45
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
    46
-- "@{text cnam'} and @{text vnam'} are intended to be isomorphic 
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    47
    to @{text cnam} and @{text vnam}"
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    48
axioms 
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
    49
  inj_cnam':  "(cnam' x = cnam' y) = (x = y)"
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
    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
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
    52
  surj_cnam': "\<exists>m. n = cnam' m"
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
    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
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
    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
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    57
abbreviation Base :: cname
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    58
  where "Base == cnam' Base'"
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    59
abbreviation Ext :: cname
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    60
  where "Ext == cnam' Ext'"
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    61
abbreviation vee :: vname
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    62
  where "vee == VName (vnam' vee')"
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    63
abbreviation x :: vname
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    64
  where "x == VName (vnam' x')"
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    65
abbreviation e :: vname
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    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
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    71
  Base_not_Xcpt:   "Base \<noteq> Xcpt z"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    72
  Ext_not_Xcpt:    "Ext  \<noteq> Xcpt z"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    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
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    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
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    78
declare Base_not_Object [symmetric, simp]
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    79
declare Ext_not_Object  [symmetric, simp]
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    80
declare Base_not_Xcpt [symmetric, simp]
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    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
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    88
  test    ::  stmt
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    89
  foo   ::  mname
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    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
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    96
           [(vee, PrimT Boolean)], 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    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
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    99
               (LAcc x)..vee:=Lit (Intg Numeral1)),
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   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
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   102
           [(vee, PrimT Integer)], 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   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
08e1610c1dcb added type annotation to Call
oheimb
parents: 10613
diff changeset
   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
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 16417
diff changeset
   109
abbreviation
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20768
diff changeset
   110
  NP  :: xcpt where
20768
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 16417
diff changeset
   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
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 16417
diff changeset
   115
  "tprg == [ObjectC, BaseC, ExtC, ClassCastC, NullPointerC, OutOfMemoryC]"
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 16417
diff changeset
   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
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 16417
diff changeset
   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
40f414b87655 tuned ML declarations;
wenzelm
parents: 23894
diff changeset
   126
lemmas map_of_Cons = map_of.simps(2)
40f414b87655 tuned ML declarations;
wenzelm
parents: 23894
diff changeset
   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
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   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
644b62cf678f arbitrary is undefined
haftmann
parents: 24783
diff changeset
   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
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   141
lemma class_tprg_NP [simp]: "class tprg (Xcpt NP) = Some (Object, [], [])"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   142
apply (unfold ObjectC_def NullPointerC_def ClassCastC_def OutOfMemoryC_def BaseC_def ExtC_def class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   143
apply (simp (no_asm))
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   144
done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   145
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   146
lemma class_tprg_OM [simp]: "class tprg (Xcpt OutOfMemory) = Some (Object, [], [])"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   147
apply (unfold ObjectC_def NullPointerC_def ClassCastC_def OutOfMemoryC_def BaseC_def ExtC_def class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   148
apply (simp (no_asm))
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   149
done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   150
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   151
lemma class_tprg_CC [simp]: "class tprg (Xcpt ClassCast) = Some (Object, [], [])"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   152
apply (unfold ObjectC_def NullPointerC_def ClassCastC_def OutOfMemoryC_def BaseC_def ExtC_def class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   153
apply (simp (no_asm))
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   154
done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   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
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   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
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   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
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   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
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   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"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   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
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   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
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   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
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   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
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   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
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   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
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   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
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   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
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   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
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   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
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   287
"ws_cdecl tprg ObjectC \<and> 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   288
  wf_cdecl_mdecl wf_java_mdecl tprg ObjectC \<and> wf_mrT tprg ObjectC"
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   289
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   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
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   294
lemma wf_NP:
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   295
"ws_cdecl tprg NullPointerC \<and>
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   296
  wf_cdecl_mdecl wf_java_mdecl tprg NullPointerC \<and> wf_mrT tprg NullPointerC"
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   297
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   298
  wf_mrT_def wf_fdecl_def NullPointerC_def)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   299
apply (simp add: class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   300
apply (fold NullPointerC_def class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   301
apply auto
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   302
done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   303
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   304
lemma wf_OM:
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   305
"ws_cdecl tprg OutOfMemoryC \<and>
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   306
  wf_cdecl_mdecl wf_java_mdecl tprg OutOfMemoryC \<and> wf_mrT tprg OutOfMemoryC"
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   307
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   308
  wf_mrT_def wf_fdecl_def OutOfMemoryC_def)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   309
apply (simp add: class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   310
apply (fold OutOfMemoryC_def class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   311
apply auto
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   312
done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   313
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   314
lemma wf_CC:
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   315
"ws_cdecl tprg ClassCastC \<and>
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   316
  wf_cdecl_mdecl wf_java_mdecl tprg ClassCastC \<and> wf_mrT tprg ClassCastC"
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   317
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   318
  wf_mrT_def wf_fdecl_def ClassCastC_def)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   319
apply (simp add: class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   320
apply (fold ClassCastC_def class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   321
apply auto
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   322
done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   323
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   324
lemma wf_BaseC: 
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   325
"ws_cdecl tprg BaseC \<and>
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   326
  wf_cdecl_mdecl wf_java_mdecl tprg BaseC \<and> wf_mrT tprg BaseC"
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   327
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   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
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   331
apply (rule mp) defer apply (rule wf_foo_Base)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   332
apply (auto simp add: wf_mdecl_def)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   333
done
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   334
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   335
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   336
lemma wf_ExtC: 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   337
"ws_cdecl tprg ExtC \<and>
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   338
  wf_cdecl_mdecl wf_java_mdecl tprg ExtC \<and> wf_mrT tprg ExtC"
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   339
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   340
  wf_mrT_def wf_fdecl_def ExtC_def)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   341
apply (simp (no_asm))
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   342
apply (fold ExtC_def)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   343
apply (rule mp) defer apply (rule wf_foo_Ext)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   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
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   350
lemma [simp]: "fst ObjectC = Object" by (simp add: ObjectC_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   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
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   354
apply (unfold wf_prog_def ws_prog_def Let_def)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   355
apply (simp add: wf_ObjectC wf_BaseC wf_ExtC wf_NP wf_OM wf_CC unique_classes)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   356
apply (rule wf_syscls)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   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 *}
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   374
lemma wt_test: "(tprg, empty(e\<mapsto>Class Base))\<turnstile>  
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
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   376
apply (tactic t) -- ";;"
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   377
apply  (tactic t) -- "Expr"
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   378
apply  (tactic t) -- "LAss"
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   379
apply    simp -- {* @{text "e \<noteq> This"} *}
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   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
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   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
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   386
apply (tactic t) -- "Expr"
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   387
apply (tactic t) -- "Call"
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   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
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   391
apply  (tactic t) -- "Cons"
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908