src/HOL/MicroJava/J/Example.thy
author wenzelm
Tue, 06 Oct 2015 15:14:28 +0200
changeset 61337 4645502c3c64
parent 59498 50b60f501b05
child 61361 8b5f00202e1a
permissions -rw-r--r--
fewer aliases for toplevel theorem statements;
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
58886
8a6cac7c7247 modernized header;
wenzelm
parents: 58310
diff changeset
     6
section {* 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
58310
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
    39
datatype cnam' = Base' | Ext'
91ea607a34d8 updated news
blanchet
parents: 58249
diff changeset
    40
datatype vnam' = vee' | x' | e'
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    41
45827
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    42
text {*
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    43
  @{text cnam'} and @{text vnam'} are intended to be isomorphic 
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    44
  to @{text cnam} and @{text vnam}
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    45
*}
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    46
45827
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    47
axiomatization cnam' :: "cnam' => cname"
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    48
where
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    49
  inj_cnam':  "(cnam' x = cnam' y) = (x = y)" and
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    50
  surj_cnam': "\<exists>m. n = cnam' m"
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    51
45827
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    52
axiomatization vnam' :: "vnam' => vnam"
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    53
where
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    54
  inj_vnam':  "(vnam' x = vnam' y) = (x = y)" and
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
    55
  surj_vnam': "\<exists>m. n = vnam' m"
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    56
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
    57
declare inj_cnam' [simp] inj_vnam' [simp]
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    58
35102
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    59
abbreviation Base :: cname
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    60
  where "Base == cnam' Base'"
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    61
abbreviation Ext :: cname
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    62
  where "Ext == cnam' Ext'"
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    63
abbreviation vee :: vname
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    64
  where "vee == VName (vnam' vee')"
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    65
abbreviation x :: vname
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    66
  where "x == VName (vnam' x')"
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    67
abbreviation e :: vname
cc7a0b9f938c modernized translations;
wenzelm
parents: 33954
diff changeset
    68
  where "e == VName (vnam' e')"
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    69
45827
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    70
axiomatization where
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    71
  Base_not_Object: "Base \<noteq> Object" and
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    72
  Ext_not_Object:  "Ext  \<noteq> Object" and
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    73
  Base_not_Xcpt:   "Base \<noteq> Xcpt z" and
66c68453455c modernized specifications;
wenzelm
parents: 45605
diff changeset
    74
  Ext_not_Xcpt:    "Ext  \<noteq> Xcpt z" and
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    75
  e_not_This:      "e \<noteq> This"  
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
    76
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
    77
declare Base_not_Object [simp] Ext_not_Object [simp]
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    78
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
    79
declare e_not_This [simp]
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    80
declare Base_not_Object [symmetric, simp]
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    81
declare Ext_not_Object  [symmetric, simp]
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    82
declare Base_not_Xcpt [symmetric, simp]
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
    83
declare Ext_not_Xcpt  [symmetric, simp]
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    84
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    85
consts
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
    86
  foo_Base::  java_mb
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
    87
  foo_Ext ::  java_mb
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
    88
  BaseC   :: "java_mb cdecl"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
    89
  ExtC    :: "java_mb cdecl"
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    90
  test    ::  stmt
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    91
  foo   ::  mname
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    92
  a   ::  loc
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
    93
  b       ::  loc
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    94
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
    95
defs
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
    96
  foo_Base_def:"foo_Base == ([x],[],Skip,LAcc x)"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
    97
  BaseC_def:"BaseC == (Base, (Object, 
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    98
           [(vee, PrimT Boolean)], 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
    99
           [((foo,[Class Base]),Class Base,foo_Base)]))"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   100
  foo_Ext_def:"foo_Ext == ([x],[],Expr( {Ext}Cast Ext
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   101
               (LAcc x)..vee:=Lit (Intg Numeral1)),
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   102
           Lit Null)"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   103
  ExtC_def: "ExtC  == (Ext,  (Base  , 
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   104
           [(vee, PrimT Integer)], 
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   105
           [((foo,[Class Base]),Class Ext,foo_Ext)]))"
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
   106
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   107
  test_def:"test == Expr(e::=NewC Ext);; 
10763
08e1610c1dcb added type annotation to Call
oheimb
parents: 10613
diff changeset
   108
                    Expr({Base}LAcc e..foo({[Class Base]}[Lit Null]))"
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
   109
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
   110
20768
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 16417
diff changeset
   111
abbreviation
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20768
diff changeset
   112
  NP  :: xcpt where
20768
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 16417
diff changeset
   113
  "NP == NullPointer"
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
   114
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20768
diff changeset
   115
abbreviation
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20768
diff changeset
   116
  tprg  ::"java_mb prog" where
20768
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 16417
diff changeset
   117
  "tprg == [ObjectC, BaseC, ExtC, ClassCastC, NullPointerC, OutOfMemoryC]"
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 16417
diff changeset
   118
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20768
diff changeset
   119
abbreviation
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20768
diff changeset
   120
  obj1  :: obj where
20768
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 16417
diff changeset
   121
  "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
   122
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20768
diff changeset
   123
abbreviation "s0 == Norm    (empty, empty)"
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20768
diff changeset
   124
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
   125
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
   126
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
   127
24074
40f414b87655 tuned ML declarations;
wenzelm
parents: 23894
diff changeset
   128
lemmas map_of_Cons = map_of.simps(2)
40f414b87655 tuned ML declarations;
wenzelm
parents: 23894
diff changeset
   129
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   130
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
   131
apply (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   132
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   133
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
   134
apply (simp (no_asm_simp))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   135
done
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   136
declare map_of_Cons [simp del] -- "sic!"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   137
28524
644b62cf678f arbitrary is undefined
haftmann
parents: 24783
diff changeset
   138
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
   139
apply (unfold ObjectC_def class_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   140
apply (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   141
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   142
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   143
lemma class_tprg_NP [simp]: "class tprg (Xcpt NP) = Some (Object, [], [])"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   144
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
   145
apply (simp (no_asm))
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   146
done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   147
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   148
lemma class_tprg_OM [simp]: "class tprg (Xcpt OutOfMemory) = Some (Object, [], [])"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   149
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
   150
apply (simp (no_asm))
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   151
done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   152
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   153
lemma class_tprg_CC [simp]: "class tprg (Xcpt ClassCast) = Some (Object, [], [])"
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   154
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
   155
apply (simp (no_asm))
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   156
done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   157
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   158
lemma class_tprg_Base [simp]: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   159
"class tprg Base = Some (Object,  
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   160
    [(vee, PrimT Boolean)],  
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   161
          [((foo, [Class Base]), Class Base, foo_Base)])"
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   162
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
   163
apply (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   164
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   165
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   166
lemma class_tprg_Ext [simp]: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   167
"class tprg Ext = Some (Base,  
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   168
    [(vee, PrimT Integer)],  
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   169
          [((foo, [Class Base]), Class Ext, foo_Ext)])"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   170
apply (unfold ObjectC_def BaseC_def ExtC_def class_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   171
apply (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   172
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   173
33954
1bc3b688548c backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents: 28524
diff changeset
   174
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
   175
apply (auto dest!: tranclD subcls1D)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   176
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   177
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   178
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
   179
apply (erule rtrancl_induct)
11026
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
apply (drule subcls1D)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   182
apply auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   183
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   184
33954
1bc3b688548c backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents: 28524
diff changeset
   185
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
   186
apply (auto dest!: tranclD subcls1D)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   187
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   188
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   189
lemma class_tprgD: 
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   190
"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
   191
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
   192
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
   193
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   194
33954
1bc3b688548c backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents: 28524
diff changeset
   195
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
   196
apply (auto dest!: tranclD subcls1D)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   197
apply (frule class_tprgD)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   198
apply (auto dest!:)
33954
1bc3b688548c backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents: 28524
diff changeset
   199
apply (drule rtranclD)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   200
apply auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   201
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   202
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   203
lemma unique_classes: "unique tprg"
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   204
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
   205
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   206
45605
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 36319
diff changeset
   207
lemmas subcls_direct = subcls1I [THEN r_into_rtrancl [where r="subcls1 G"]] for G
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   208
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   209
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
   210
apply (rule subcls_direct)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   211
apply auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   212
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   213
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   214
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
   215
apply (rule widen.subcls)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   216
apply (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   217
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   218
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   219
declare ty_expr_ty_exprs_wt_stmt.intros [intro!]
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   220
33954
1bc3b688548c backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents: 28524
diff changeset
   221
lemma acyclic_subcls1': "acyclic (subcls1 tprg)"
1bc3b688548c backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents: 28524
diff changeset
   222
apply (rule acyclicI)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   223
apply safe
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   224
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   225
33954
1bc3b688548c backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents: 28524
diff changeset
   226
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
   227
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   228
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
   229
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   230
lemma fields_Object [simp]: "fields (tprg, Object) = []"
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   231
apply (subst fields_rec')
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   232
apply   auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   233
done
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
declare is_class_def [simp]
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   236
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   237
lemma fields_Base [simp]: "fields (tprg,Base) = [((vee, Base), PrimT Boolean)]"
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   238
apply (subst fields_rec')
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   239
apply   auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   240
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   241
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   242
lemma fields_Ext [simp]: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   243
  "fields (tprg, Ext)  = [((vee, Ext ), PrimT Integer)] @ fields (tprg, Base)"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   244
apply (rule trans)
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   245
apply  (rule fields_rec')
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   246
apply   auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   247
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   248
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   249
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
   250
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   251
lemma method_Object [simp]: "method (tprg,Object) = map_of []"
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   252
apply (subst method_rec')
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   253
apply  auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   254
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   255
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   256
lemma method_Base [simp]: "method (tprg, Base) = map_of  
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   257
  [((foo, [Class Base]), Base, (Class Base, foo_Base))]"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   258
apply (rule trans)
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   259
apply  (rule method_rec')
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   260
apply  auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   261
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   262
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   263
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
   264
  [((foo, [Class Base]), Ext , (Class Ext, foo_Ext))])"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   265
apply (rule trans)
24783
5a3e336a2e37 avoid internal names;
wenzelm
parents: 24074
diff changeset
   266
apply  (rule method_rec')
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   267
apply  auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   268
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   269
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   270
lemma wf_foo_Base: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   271
"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
   272
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
   273
apply auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   274
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   275
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   276
lemma wf_foo_Ext: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   277
"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
   278
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
   279
apply auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   280
apply  (rule ty_expr_ty_exprs_wt_stmt.Cast)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   281
prefer 2
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   282
apply   (simp)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   283
apply   (rule_tac [2] cast.subcls)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   284
apply   (unfold field_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   285
apply   auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   286
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   287
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   288
lemma wf_ObjectC: 
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   289
"ws_cdecl tprg ObjectC \<and> 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   290
  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
   291
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   292
  wf_mrT_def wf_fdecl_def ObjectC_def)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   293
apply (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   294
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   295
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   296
lemma wf_NP:
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   297
"ws_cdecl tprg NullPointerC \<and>
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   298
  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
   299
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   300
  wf_mrT_def wf_fdecl_def NullPointerC_def)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   301
apply (simp add: class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   302
apply (fold NullPointerC_def class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   303
apply auto
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   304
done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   305
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   306
lemma wf_OM:
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   307
"ws_cdecl tprg OutOfMemoryC \<and>
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   308
  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
   309
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   310
  wf_mrT_def wf_fdecl_def OutOfMemoryC_def)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   311
apply (simp add: class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   312
apply (fold OutOfMemoryC_def class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   313
apply auto
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   314
done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   315
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   316
lemma wf_CC:
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   317
"ws_cdecl tprg ClassCastC \<and>
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   318
  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
   319
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   320
  wf_mrT_def wf_fdecl_def ClassCastC_def)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   321
apply (simp add: class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   322
apply (fold ClassCastC_def class_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   323
apply auto
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   324
done
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   325
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   326
lemma wf_BaseC: 
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   327
"ws_cdecl tprg BaseC \<and>
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   328
  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
   329
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   330
  wf_mrT_def wf_fdecl_def BaseC_def)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   331
apply (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   332
apply (fold BaseC_def)
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   333
apply (rule mp) defer apply (rule wf_foo_Base)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   334
apply (auto simp add: wf_mdecl_def)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   335
done
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   336
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   337
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   338
lemma wf_ExtC: 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   339
"ws_cdecl tprg ExtC \<and>
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   340
  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
   341
apply (unfold ws_cdecl_def wf_cdecl_mdecl_def
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   342
  wf_mrT_def wf_fdecl_def ExtC_def)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   343
apply (simp (no_asm))
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   344
apply (fold ExtC_def)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   345
apply (rule mp) defer apply (rule wf_foo_Ext)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   346
apply (auto simp add: wf_mdecl_def)
33954
1bc3b688548c backported parts of abstract byte code verifier from AFP/Jinja
haftmann
parents: 28524
diff changeset
   347
apply (drule rtranclD)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   348
apply auto
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   349
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   350
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   351
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   352
lemma [simp]: "fst ObjectC = Object" by (simp add: ObjectC_def)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   353
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   354
lemma wf_tprg: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   355
"wf_prog wf_java_mdecl tprg"
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 12951
diff changeset
   356
apply (unfold wf_prog_def ws_prog_def Let_def)
12951
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   357
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
   358
apply (rule wf_syscls)
a9fdcb71d252 introduces SystemClasses and BVExample
kleing
parents: 12911
diff changeset
   359
apply (simp add: SystemClasses_def)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   360
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   361
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   362
lemma appl_methds_foo_Base: 
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   363
"appl_methds tprg Base (foo, [NT]) =  
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   364
  {((Class Base, Class Base), [Class Base])}"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   365
apply (unfold appl_methds_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   366
apply (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   367
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   368
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   369
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
   370
  {((Class Base, Class Base), [Class Base])}"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   371
apply (unfold max_spec_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   372
apply (auto simp add: appl_methds_foo_Base)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   373
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   374
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   375
lemmas t = ty_expr_ty_exprs_wt_stmt.intros
61337
4645502c3c64 fewer aliases for toplevel theorem statements;
wenzelm
parents: 59498
diff changeset
   376
schematic_goal wt_test: "(tprg, empty(e\<mapsto>Class Base))\<turnstile>  
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   377
  Expr(e::=NewC Ext);; Expr({Base}LAcc e..foo({?pTs'}[Lit Null]))\<surd>"
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   378
apply (rule ty_expr_ty_exprs_wt_stmt.intros) -- ";;"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   379
apply  (rule t) -- "Expr"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   380
apply  (rule t) -- "LAss"
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   381
apply    simp -- {* @{text "e \<noteq> This"} *}
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   382
apply    (rule t) -- "LAcc"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   383
apply     (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   384
apply    (simp (no_asm))
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   385
apply   (rule t) -- "NewC"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   386
apply   (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   387
apply  (simp (no_asm))
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   388
apply (rule t) -- "Expr"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   389
apply (rule t) -- "Call"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   390
apply   (rule t) -- "LAcc"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   391
apply    (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   392
apply   (simp (no_asm))
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   393
apply  (rule t) -- "Cons"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   394
apply   (rule t) -- "Lit"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   395
apply   (simp (no_asm))
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   396
apply  (rule t) -- "Nil"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   397
apply (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   398
apply (rule max_spec_foo_Base)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   399
done
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
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   402
lemmas e = NewCI eval_evals_exec.intros
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   403
declare split_if [split del]
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   404
declare init_vars_def [simp] c_hupd_def [simp] cast_ok_def [simp]
61337
4645502c3c64 fewer aliases for toplevel theorem statements;
wenzelm
parents: 59498
diff changeset
   405
schematic_goal exec_test: 
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   406
" [|new_Addr (heap (snd s0)) = (a, None)|] ==>  
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   407
  tprg\<turnstile>s0 -test-> ?s"
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   408
apply (unfold test_def)
12517
360e3215f029 exception merge, cleanup, tuned
kleing
parents: 11908
diff changeset
   409
-- "?s = s3 "
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   410
apply (rule e) -- ";;"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   411
apply  (rule e) -- "Expr"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   412
apply  (rule e) -- "LAss"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   413
apply   (rule e) -- "NewC"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   414
apply    force
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   415
apply   force
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   416
apply  (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   417
apply (erule thin_rl)
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   418
apply (rule e) -- "Expr"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   419
apply (rule e) -- "Call"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   420
apply       (rule e) -- "LAcc"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   421
apply      force
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   422
apply     (rule e) -- "Cons"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   423
apply      (rule e) -- "Lit"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   424
apply     (rule e) -- "Nil"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   425
apply    (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   426
apply   (force simp add: foo_Ext_def)
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   427
apply  (simp (no_asm))
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   428
apply  (rule e) -- "Expr"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   429
apply  (rule e) -- "FAss"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   430
apply       (rule e) -- "Cast"
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   431
apply        (rule e) -- "LAcc"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   432
apply       (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   433
apply      (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   434
apply     (simp (no_asm))
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   435
apply     (rule e) -- "XcptE"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   436
apply    (simp (no_asm))
59199
wenzelm
parents: 58886
diff changeset
   437
apply   (rule surjective_pairing [symmetric, THEN[2]trans], subst Pair_eq, force)
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   438
apply  (simp (no_asm))
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   439
apply (simp (no_asm))
59498
50b60f501b05 proper context for resolve_tac, eresolve_tac, dresolve_tac, forward_tac etc.;
wenzelm
parents: 59199
diff changeset
   440
apply (rule e) -- "XcptE"
11026
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   441
done
a50365d21144 converted to Isar, simplifying recursion on class hierarchy
oheimb
parents: 10763
diff changeset
   442
9346
297dcbf64526 re-structuring MicroJava; added Example; corrected := syntax; simplfied cast
oheimb
parents:
diff changeset
   443
end