author | wenzelm |
Mon, 29 Nov 1999 15:52:49 +0100 | |
changeset 8039 | a901bafe4578 |
parent 8034 | 6fc37b5c5e98 |
child 8045 | 816f566c414f |
permissions | -rw-r--r-- |
8011 | 1 |
(* Title: HOL/MicroJava/BV/Correct.thy |
2 |
ID: $Id$ |
|
3 |
Author: Cornelia Pusch |
|
4 |
Copyright 1999 Technische Universitaet Muenchen |
|
5 |
||
6 |
The invariant for the type safety proof. |
|
7 |
*) |
|
8 |
||
9 |
Correct = BVSpec + |
|
10 |
||
11 |
constdefs |
|
12 |
approx_val :: "[jvm_prog,aheap,val,ty option] \\<Rightarrow> bool" |
|
13 |
"approx_val G h v any \\<equiv> case any of None \\<Rightarrow> True | Some T \\<Rightarrow> G,h\\<turnstile>v\\<Colon>\\<preceq>T" |
|
14 |
||
15 |
approx_loc :: "[jvm_prog,aheap,val list,locvars_type] \\<Rightarrow> bool" |
|
16 |
"approx_loc G hp loc LT \\<equiv> |
|
17 |
length loc=length LT \\<and> (\\<forall>(val,any)\\<in>set (zip loc LT). approx_val G hp val any)" |
|
18 |
||
19 |
approx_stk :: "[jvm_prog,aheap,opstack,opstack_type] \\<Rightarrow> bool" |
|
20 |
"approx_stk G hp stk ST \\<equiv> approx_loc G hp stk (map Some ST)" |
|
21 |
||
22 |
correct_frame :: "[jvm_prog,aheap,state_type,nat,bytecode] \\<Rightarrow> frame \\<Rightarrow> bool" |
|
23 |
"correct_frame G hp \\<equiv> \\<lambda>(ST,LT) maxl ins (stk,loc,C,ml,pc). |
|
24 |
approx_stk G hp stk ST \\<and> approx_loc G hp loc LT \\<and> |
|
25 |
pc < length ins \\<and> length loc=length(snd ml)+maxl+1" |
|
26 |
||
27 |
consts |
|
28 |
correct_frames :: "[jvm_prog,aheap,prog_type,ty,cname,sig,frame list] \\<Rightarrow> bool" |
|
29 |
primrec |
|
30 |
"correct_frames G hp phi rT0 C0 ml0 [] = False" |
|
31 |
||
32 |
"correct_frames G hp phi rT0 C0 ml0 (f#frs) = |
|
33 |
(let (stk,loc,C,ml,pc) = f; |
|
34 |
(ST,LT) = (phi C ml) ! pc |
|
35 |
in |
|
36 |
(\\<exists>rT maxl ins. |
|
8034
6fc37b5c5e98
Various little changes like cmethd -> method and cfield -> field.
nipkow
parents:
8032
diff
changeset
|
37 |
method (G,C) ml = Some(C,rT,(maxl,ins)) \\<and> |
8032 | 38 |
(\\<exists>mn pTs k. pc = k+1 \\<and> ins!k = MI(Invoke mn pTs) \\<and> |
8011 | 39 |
(mn,pTs) = ml0 \\<and> |
40 |
(\\<exists>apTs D ST'. |
|
41 |
fst((phi C ml)!k) = (rev apTs) @ (Class D) # ST' \\<and> |
|
42 |
length apTs = length pTs \\<and> |
|
43 |
(\\<exists>D' rT' maxl' ins'. |
|
8034
6fc37b5c5e98
Various little changes like cmethd -> method and cfield -> field.
nipkow
parents:
8032
diff
changeset
|
44 |
method (G,D) (mn,pTs) = Some(D',rT',(maxl',ins')) \\<and> |
8011 | 45 |
G \\<turnstile> rT0 \\<preceq> rT') \\<and> |
46 |
correct_frame G hp (tl ST, LT) maxl ins f \\<and> |
|
47 |
correct_frames G hp phi rT C ml frs))))" |
|
48 |
||
49 |
||
50 |
constdefs |
|
51 |
correct_state :: "[jvm_prog,prog_type,jvm_state] \\<Rightarrow> bool" |
|
8032 | 52 |
("_,_\\<turnstile>JVM _\\<surd>" [51,51] 50) |
8011 | 53 |
"correct_state G phi \\<equiv> \\<lambda>(xp,hp,frs). |
54 |
case xp of |
|
55 |
None \\<Rightarrow> (case frs of |
|
56 |
[] \\<Rightarrow> True |
|
57 |
| (f#fs) \\<Rightarrow> (let (stk,loc,C,ml,pc) = f |
|
58 |
in |
|
59 |
\\<exists>rT maxl ins. |
|
8034
6fc37b5c5e98
Various little changes like cmethd -> method and cfield -> field.
nipkow
parents:
8032
diff
changeset
|
60 |
method (G,C) ml = Some(C,rT,(maxl,ins)) \\<and> |
8032 | 61 |
G\\<turnstile>h hp\\<surd> \\<and> |
8011 | 62 |
correct_frame G hp ((phi C ml) ! pc) maxl ins f \\<and> |
63 |
correct_frames G hp phi rT C ml fs)) |
|
64 |
| Some x \\<Rightarrow> True" |
|
65 |
||
66 |
end |