src/HOL/MicroJava/BV/LBVSpec.thy
author kleing
Thu, 09 Mar 2000 13:56:54 +0100
changeset 8390 e5b618f6824e
parent 8245 6acc80f7f36f
child 9012 d1bd2144ab5d
permissions -rw-r--r--
tuned for completeness of LBV
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     1
(*  Title:      HOL/MicroJava/BV/BVLightSpec.thy
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     2
    ID:         $Id$
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     3
    Author:     Gerwin Klein
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     4
    Copyright   1999 Technische Universitaet Muenchen
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     5
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     6
Specification of a lightweight bytecode verifier
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     7
*)
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     8
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
     9
LBVSpec = BVSpec +
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    10
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    11
types
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    12
  certificate       = "state_type option list" 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    13
  class_certificate = "sig \\<Rightarrow> certificate"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    14
  prog_certificate  = "cname \\<Rightarrow> class_certificate"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    15
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    16
consts
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    17
 wtl_LS :: "[load_and_store,state_type,state_type,p_count,p_count] \\<Rightarrow> bool"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    18
primrec
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    19
"wtl_LS (Load idx) s s' max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    20
 (let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    21
  in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    22
  pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    23
  idx < length LT \\<and> 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    24
  (\\<exists>ts. (LT ! idx) = Some ts \\<and>  
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    25
   (ts # ST , LT) = s'))"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    26
  
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    27
"wtl_LS (Store idx) s s' max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    28
 (let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    29
  in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    30
  pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    31
  idx < length LT \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    32
  (\\<exists>ts ST'. ST = ts # ST' \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    33
   (ST' , LT[idx:=Some ts]) = s'))"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    34
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    35
"wtl_LS (Bipush i) s s' max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    36
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    37
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    38
	 pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    39
	 ((PrimT Integer) # ST , LT) = s')"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    40
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    41
"wtl_LS (Aconst_null) s s' max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    42
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    43
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    44
	 pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    45
	 (NT # ST , LT) = s')"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    46
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    47
consts
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    48
 wtl_MO	:: "[manipulate_object,jvm_prog,state_type,state_type,p_count,p_count] \\<Rightarrow> bool" 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    49
primrec
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    50
"wtl_MO (Getfield F C) G s s' max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    51
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    52
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    53
	 pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    54
	 is_class G C \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    55
	 (\\<exists>T oT ST'. field (G,C) F = Some(C,T) \\<and>
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
    56
                          ST = oT # ST'  \\<and> 
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
    57
		                  G \\<turnstile> oT \\<preceq> (Class C) \\<and>
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
    58
		          (T # ST' , LT) = s'))"
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    59
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    60
"wtl_MO (Putfield F C) G s s' max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    61
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    62
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    63
	 pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    64
	 is_class G C \\<and> 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    65
	 (\\<exists>T vT oT ST'.
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    66
             field (G,C) F = Some(C,T) \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    67
             ST = vT # oT # ST' \\<and> 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    68
             G \\<turnstile> oT \\<preceq> (Class C) \\<and>
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
    69
             G \\<turnstile> vT \\<preceq> T  \\<and>
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    70
             (ST' , LT) = s'))"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    71
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    72
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    73
consts 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    74
 wtl_CO	:: "[create_object,jvm_prog,state_type,state_type,p_count,p_count] \\<Rightarrow> bool" 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    75
primrec
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    76
"wtl_CO (New C) G s s' max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    77
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    78
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    79
	 pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    80
	 is_class G C \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    81
	 ((Class C) # ST , LT) = s')"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    82
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    83
consts
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    84
 wtl_CH	:: "[check_object,jvm_prog,state_type,state_type,p_count,p_count] \\<Rightarrow> bool" 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    85
primrec
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    86
"wtl_CH (Checkcast C) G s s' max_pc pc = 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    87
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    88
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    89
	 pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    90
	 is_class G C \\<and> 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    91
	 (\\<exists>rt ST'. ST = RefT rt # ST' \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    92
                   (Class C # ST' , LT) = s'))"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    93
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    94
consts 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    95
 wtl_OS	:: "[op_stack,state_type,state_type,p_count,p_count] \\<Rightarrow> bool" 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    96
primrec
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    97
"wtl_OS Pop s s' max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    98
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    99
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   100
	 \\<exists>ts ST'. pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   101
		ST = ts # ST' \\<and> 	 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   102
		(ST' , LT) = s')"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   103
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   104
"wtl_OS Dup s s' max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   105
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   106
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   107
	 pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   108
	 (\\<exists>ts ST'. ST = ts # ST' \\<and> 	 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   109
		   (ts # ts # ST' , LT) = s'))"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   110
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   111
"wtl_OS Dup_x1 s s' max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   112
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   113
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   114
	 pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   115
	 (\\<exists>ts1 ts2 ST'. ST = ts1 # ts2 # ST' \\<and> 	 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   116
		        (ts1 # ts2 # ts1 # ST' , LT) = s'))"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   117
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   118
"wtl_OS Dup_x2 s s' max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   119
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   120
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   121
	 pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   122
	 (\\<exists>ts1 ts2 ts3 ST'. ST = ts1 # ts2 # ts3 # ST' \\<and> 	 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   123
		            (ts1 # ts2 # ts3 # ts1 # ST' , LT) = s'))"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   124
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   125
"wtl_OS Swap s s' max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   126
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   127
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   128
	 pc+1 < max_pc \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   129
	 (\\<exists>ts ts' ST'. ST = ts' # ts # ST' \\<and> 	 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   130
		       (ts # ts' # ST' , LT) = s'))"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   131
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   132
consts 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   133
 wtl_BR	:: "[branch,jvm_prog,state_type,state_type,certificate,p_count,p_count] \\<Rightarrow> bool" 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   134
primrec
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   135
"wtl_BR (Ifcmpeq branch) G s s' cert max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   136
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   137
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   138
	 pc+1 < max_pc \\<and> (nat(int pc+branch)) < max_pc \\<and> 
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   139
	 (\\<exists>ts ts' ST'. ST = ts # ts' # ST' \\<and>
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   140
          ((\\<exists>p. ts = PrimT p \\<and> ts' = PrimT p) \\<or>
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   141
           (\\<exists>r r'. ts = RefT r \\<and> ts' = RefT r')) \\<and>
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   142
		       ((ST' , LT) = s') \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   143
            cert ! (nat(int pc+branch)) \\<noteq> None \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   144
		       G \\<turnstile> (ST' , LT) <=s the (cert ! (nat(int pc+branch)))))"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   145
  
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   146
"wtl_BR (Goto branch) G s s' cert max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   147
	((let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   148
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   149
	 (nat(int pc+branch)) < max_pc \\<and> cert ! (nat(int pc+branch)) \\<noteq> None \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   150
	 G \\<turnstile> (ST , LT) <=s the (cert ! (nat(int pc+branch)))) \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   151
   (cert ! (pc+1) = Some s'))"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   152
  
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   153
consts
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   154
 wtl_MI :: "[meth_inv,jvm_prog,state_type,state_type,certificate,p_count,p_count] \\<Rightarrow> bool" 
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   155
primrec
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   156
"wtl_MI (Invoke mn fpTs) G s s' cert max_pc pc =
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   157
	(let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   158
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   159
         pc+1 < max_pc \\<and>
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   160
         (\\<exists>apTs X ST'. ST = (rev apTs) @ (X # ST') \\<and>
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   161
         length apTs = length fpTs \\<and>
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   162
         (\\<exists>s''. cert ! (pc+1) = Some s'' \\<and> 
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   163
         ((s'' = s' \\<and> X = NT) \\<or>
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   164
          ((G \\<turnstile> s' <=s s'') \\<and> (\\<exists>C. X = Class C \\<and>  
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   165
          (\\<forall>(aT,fT)\\<in>set(zip apTs fpTs). G \\<turnstile> aT \\<preceq> fT) \\<and> 
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   166
          (\\<exists>D rT b. method (G,C) (mn,fpTs) = Some(D,rT,b) \\<and>
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   167
          (rT # ST' , LT) = s')))))))"
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   168
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   169
consts
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   170
 wtl_MR	:: "[meth_ret,jvm_prog,ty,state_type,state_type,certificate,p_count,p_count] \\<Rightarrow> bool"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   171
primrec
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   172
  "wtl_MR Return G rT s s' cert max_pc pc = 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   173
	((let (ST,LT) = s
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   174
	 in
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   175
	 (\\<exists>T ST'. ST = T # ST' \\<and> G \\<turnstile> T \\<preceq> rT)) \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   176
   (cert ! (pc+1) = Some s'))"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   177
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   178
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   179
consts 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   180
 wtl_inst :: "[instr,jvm_prog,ty,state_type,state_type,certificate,p_count,p_count] \\<Rightarrow> bool"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   181
 primrec
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   182
 "wtl_inst (LS ins) G rT s s' cert max_pc pc = wtl_LS ins s s' max_pc pc"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   183
 "wtl_inst (CO ins) G rT s s' cert max_pc pc = wtl_CO ins G s s' max_pc pc"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   184
 "wtl_inst (MO ins) G rT s s' cert max_pc pc = wtl_MO ins G s s' max_pc pc"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   185
 "wtl_inst (CH ins) G rT s s' cert max_pc pc = wtl_CH ins G s s' max_pc pc"
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   186
 "wtl_inst (MI ins) G rT s s' cert max_pc pc = wtl_MI ins G s s' cert max_pc pc"
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   187
 "wtl_inst (MR ins) G rT s s' cert max_pc pc = wtl_MR ins G rT s s' cert max_pc pc"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   188
 "wtl_inst (OS ins) G rT s s' cert max_pc pc = wtl_OS ins s s' max_pc pc"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   189
 "wtl_inst (BR ins) G rT s s' cert max_pc pc = wtl_BR ins G s s' cert max_pc pc"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   190
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   191
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   192
constdefs
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   193
wtl_inst_option :: "[instr,jvm_prog,ty,state_type,state_type,certificate,p_count,p_count] \\<Rightarrow> bool"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   194
"wtl_inst_option i G rT s0 s1 cert max_pc pc \\<equiv>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   195
     (case cert!pc of 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   196
          None     \\<Rightarrow> wtl_inst i G rT s0 s1 cert max_pc pc
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   197
        | Some s0' \\<Rightarrow> (G \\<turnstile> s0 <=s s0') \\<and>
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   198
                      wtl_inst i G rT s0' s1 cert max_pc pc)"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   199
  
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   200
consts
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   201
 wtl_inst_list :: "[instr list,jvm_prog,ty,state_type,state_type,certificate,p_count,p_count] \\<Rightarrow> bool"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   202
primrec
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   203
  "wtl_inst_list [] G rT s0 s2 cert max_pc pc = (s0 = s2)"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   204
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   205
  "wtl_inst_list (instr#is) G rT s0 s2 cert max_pc pc =
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   206
     (\\<exists>s1. wtl_inst_option instr G rT s0 s1 cert max_pc pc \\<and> 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   207
           wtl_inst_list is G rT s1 s2 cert max_pc (pc+1))"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   208
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   209
constdefs
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   210
 wtl_method :: "[jvm_prog,cname,ty list,ty,nat,instr list,certificate] \\<Rightarrow> bool" 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   211
 "wtl_method G C pTs rT mxl ins cert \\<equiv> 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   212
	let max_pc = length ins 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   213
        in 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   214
	0 < max_pc \\<and>  
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   215
        (\\<exists>s2. wtl_inst_list ins G rT 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   216
                            ([],(Some(Class C))#((map Some pTs))@(replicate mxl None))
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   217
                            s2 cert max_pc 0)"
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   218
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   219
 wtl_jvm_prog :: "[jvm_prog,prog_certificate] \\<Rightarrow> bool" 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   220
 "wtl_jvm_prog G cert \\<equiv> 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   221
    wf_prog (\\<lambda>G C (sig,rT,maxl,b). 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   222
               wtl_method G C (snd sig) rT maxl b (cert C sig)) G" 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   223
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   224
end