author | nipkow |
Thu, 30 May 2002 10:12:52 +0200 | |
changeset 13187 | e5434b822a96 |
parent 13006 | 51c5f3f11d16 |
child 13214 | 2aa33ed5f526 |
permissions | -rw-r--r-- |
8011 | 1 |
(* Title: HOL/MicroJava/BV/BVSpec.thy |
2 |
ID: $Id$ |
|
12516 | 3 |
Author: Cornelia Pusch, Gerwin Klein |
8011 | 4 |
Copyright 1999 Technische Universitaet Muenchen |
5 |
||
6 |
*) |
|
7 |
||
12911 | 8 |
header {* \isaheader{The Bytecode Verifier}\label{sec:BVSpec} *} |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9559
diff
changeset
|
9 |
|
12516 | 10 |
theory BVSpec = Effect: |
11 |
||
12 |
text {* |
|
13 |
This theory contains a specification of the BV. The specification |
|
14 |
describes correct typings of method bodies; it corresponds |
|
15 |
to type \emph{checking}. |
|
16 |
*} |
|
8011 | 17 |
|
18 |
constdefs |
|
12516 | 19 |
wt_instr :: "[instr,jvm_prog,ty,method_type,nat,p_count, |
13006 | 20 |
exception_table,p_count] \<Rightarrow> bool" |
12516 | 21 |
"wt_instr i G rT phi mxs max_pc et pc == |
22 |
app i G mxs rT pc et (phi!pc) \<and> |
|
23 |
(\<forall>(pc',s') \<in> set (eff i G pc et (phi!pc)). pc' < max_pc \<and> G \<turnstile> s' <=' phi!pc')" |
|
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
24 |
|
13006 | 25 |
wt_start :: "[jvm_prog,cname,ty list,nat,method_type] \<Rightarrow> bool" |
12516 | 26 |
"wt_start G C pTs mxl phi == |
27 |
G \<turnstile> Some ([],(OK (Class C))#((map OK pTs))@(replicate mxl Err)) <=' phi!0" |
|
8011 | 28 |
|
12516 | 29 |
wt_method :: "[jvm_prog,cname,ty list,ty,nat,nat,instr list, |
13006 | 30 |
exception_table,method_type] \<Rightarrow> bool" |
12516 | 31 |
"wt_method G C pTs rT mxs mxl ins et phi == |
32 |
let max_pc = length ins in |
|
33 |
0 < max_pc \<and> wt_start G C pTs mxl phi \<and> |
|
13006 | 34 |
(\<forall>pc. pc<max_pc \<longrightarrow> wt_instr (ins ! pc) G rT phi mxs max_pc et pc)" |
8011 | 35 |
|
13006 | 36 |
wt_jvm_prog :: "[jvm_prog,prog_type] \<Rightarrow> bool" |
12516 | 37 |
"wt_jvm_prog G phi == |
38 |
wf_prog (\<lambda>G C (sig,rT,(maxs,maxl,b,et)). |
|
39 |
wt_method G C (snd sig) rT maxs maxl b et (phi C sig)) G" |
|
9559 | 40 |
|
41 |
||
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
42 |
lemma wt_jvm_progD: |
13006 | 43 |
"wt_jvm_prog G phi \<Longrightarrow> (\<exists>wt. wf_prog wt G)" |
12516 | 44 |
by (unfold wt_jvm_prog_def, blast) |
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
45 |
|
10629 | 46 |
lemma wt_jvm_prog_impl_wt_instr: |
13006 | 47 |
"\<lbrakk> wt_jvm_prog G phi; is_class G C; |
48 |
method (G,C) sig = Some (C,rT,maxs,maxl,ins,et); pc < length ins \<rbrakk> |
|
49 |
\<Longrightarrow> wt_instr (ins!pc) G rT (phi C sig) maxs (length ins) et pc"; |
|
12516 | 50 |
by (unfold wt_jvm_prog_def, drule method_wf_mdecl, |
51 |
simp, simp, simp add: wf_mdecl_def wt_method_def) |
|
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
52 |
|
10629 | 53 |
lemma wt_jvm_prog_impl_wt_start: |
13006 | 54 |
"\<lbrakk> wt_jvm_prog G phi; is_class G C; |
55 |
method (G,C) sig = Some (C,rT,maxs,maxl,ins,et) \<rbrakk> \<Longrightarrow> |
|
12516 | 56 |
0 < (length ins) \<and> wt_start G C (snd sig) maxl (phi C sig)" |
57 |
by (unfold wt_jvm_prog_def, drule method_wf_mdecl, |
|
58 |
simp, simp, simp add: wf_mdecl_def wt_method_def) |
|
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
59 |
|
8011 | 60 |
end |