author | kleing |
Wed, 09 Aug 2000 11:53:00 +0200 | |
changeset 9559 | 1f99296758c2 |
parent 9549 | 40d64cb4f4e6 |
child 9757 | 1024a2d80ac0 |
permissions | -rw-r--r-- |
8011 | 1 |
(* Title: HOL/MicroJava/BV/BVSpec.thy |
2 |
ID: $Id$ |
|
3 |
Author: Cornelia Pusch |
|
4 |
Copyright 1999 Technische Universitaet Muenchen |
|
5 |
||
6 |
Specification of bytecode verifier |
|
7 |
*) |
|
8 |
||
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
9 |
theory BVSpec = Step : |
8011 | 10 |
|
11 |
types |
|
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
12 |
method_type = "state_type list" |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
13 |
class_type = "sig \\<Rightarrow> method_type" |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
14 |
prog_type = "cname \\<Rightarrow> class_type" |
8011 | 15 |
|
16 |
constdefs |
|
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
17 |
wt_instr :: "[instr,jvm_prog,ty,method_type,p_count,p_count] \\<Rightarrow> bool" |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
18 |
"wt_instr i G rT phi max_pc pc \\<equiv> |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
19 |
app (i, G, rT, phi!pc) \\<and> |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
20 |
(\\<forall> pc' \\<in> (succs i pc). pc' < max_pc \\<and> (G \\<turnstile> the (step (i, G, phi!pc)) <=s phi!pc'))" |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
21 |
|
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
22 |
wt_start :: "[jvm_prog,cname,ty list,nat,method_type] \\<Rightarrow> bool" |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
23 |
"wt_start G C pTs mxl phi \\<equiv> |
8023 | 24 |
G \\<turnstile> ([],(Some(Class C))#((map Some pTs))@(replicate mxl None)) <=s phi!0" |
8011 | 25 |
|
26 |
||
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
27 |
wt_method :: "[jvm_prog,cname,ty list,ty,nat,instr list,method_type] \\<Rightarrow> bool" |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
28 |
"wt_method G C pTs rT mxl ins phi \\<equiv> |
8011 | 29 |
let max_pc = length ins |
30 |
in |
|
8386
3e56677d3b98
minor adjustments in branch and method invocation for completeness of LBV
kleing
parents:
8200
diff
changeset
|
31 |
length ins < length phi \\<and> 0 < max_pc \\<and> wt_start G C pTs mxl phi \\<and> |
8011 | 32 |
(\\<forall>pc. pc<max_pc \\<longrightarrow> wt_instr (ins ! pc) G rT phi max_pc pc)" |
33 |
||
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
34 |
wt_jvm_prog :: "[jvm_prog,prog_type] \\<Rightarrow> bool" |
8011 | 35 |
"wt_jvm_prog G phi \\<equiv> |
36 |
wf_prog (\\<lambda>G C (sig,rT,maxl,b). |
|
37 |
wt_method G C (snd sig) rT maxl b (phi C sig)) G" |
|
38 |
||
9559 | 39 |
|
40 |
||
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
41 |
lemma wt_jvm_progD: |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
42 |
"wt_jvm_prog G phi \\<Longrightarrow> (\\<exists>wt. wf_prog wt G)" |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
43 |
by (unfold wt_jvm_prog_def, blast) |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
44 |
|
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
45 |
lemma wt_jvm_prog_impl_wt_instr: |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
46 |
"\\<lbrakk> wt_jvm_prog G phi; method (G,C) sig = Some (C,rT,maxl,ins); pc < length ins \\<rbrakk> |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
47 |
\\<Longrightarrow> wt_instr (ins!pc) G rT (phi C sig) (length ins) pc"; |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
48 |
by (unfold wt_jvm_prog_def, drule method_wf_mdecl, |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
49 |
simp, simp add: wf_mdecl_def wt_method_def) |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
50 |
|
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
51 |
lemma wt_jvm_prog_impl_wt_start: |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
52 |
"\\<lbrakk> wt_jvm_prog G phi; method (G,C) sig = Some (C,rT,maxl,ins) \\<rbrakk> \\<Longrightarrow> |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
53 |
0 < (length ins) \\<and> wt_start G C (snd sig) maxl (phi C sig)" |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
54 |
by (unfold wt_jvm_prog_def, drule method_wf_mdecl, |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
55 |
simp, simp add: wf_mdecl_def wt_method_def) |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
56 |
|
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
57 |
lemma [simp]: |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
58 |
"succs i pc = {pc+1} \\<Longrightarrow> wt_instr i G rT phi max_pc pc = |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
59 |
(app (i, G, rT, phi!pc) \\<and> pc+1 < max_pc \\<and> |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
60 |
(G \\<turnstile> the (step (i, G, phi!pc)) <=s phi!(pc+1)))" |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
61 |
by (simp add: wt_instr_def) |
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
62 |
|
8011 | 63 |
end |
9549
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
64 |
|
40d64cb4f4e6
BV and LBV specified in terms of app and step functions
kleing
parents:
9376
diff
changeset
|
65 |