author | nipkow |
Wed, 12 Jan 2000 15:58:16 +0100 | |
changeset 8119 | 60b606eddec8 |
parent 8047 | 3a0c996cf2b2 |
child 9376 | c32c5696ec2a |
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" |
|
8119 | 16 |
"approx_loc G hp loc LT \\<equiv> list_all2 (approx_val G hp) loc LT" |
8011 | 17 |
|
18 |
approx_stk :: "[jvm_prog,aheap,opstack,opstack_type] \\<Rightarrow> bool" |
|
19 |
"approx_stk G hp stk ST \\<equiv> approx_loc G hp stk (map Some ST)" |
|
20 |
||
21 |
correct_frame :: "[jvm_prog,aheap,state_type,nat,bytecode] \\<Rightarrow> frame \\<Rightarrow> bool" |
|
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
22 |
"correct_frame G hp \\<equiv> \\<lambda>(ST,LT) maxl ins (stk,loc,C,sig,pc). |
8011 | 23 |
approx_stk G hp stk ST \\<and> approx_loc G hp loc LT \\<and> |
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
24 |
pc < length ins \\<and> length loc=length(snd sig)+maxl+1" |
8011 | 25 |
|
26 |
consts |
|
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
27 |
correct_frames :: "[jvm_prog,aheap,prog_type,ty,sig,frame list] \\<Rightarrow> bool" |
8011 | 28 |
primrec |
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
29 |
"correct_frames G hp phi rT0 sig0 [] = True" |
8011 | 30 |
|
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
31 |
"correct_frames G hp phi rT0 sig0 (f#frs) = |
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
32 |
(let (stk,loc,C,sig,pc) = f; |
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
33 |
(ST,LT) = (phi C sig) ! pc |
8011 | 34 |
in |
35 |
(\\<exists>rT maxl ins. |
|
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
36 |
method (G,C) sig = Some(C,rT,(maxl,ins)) \\<and> |
8032 | 37 |
(\\<exists>mn pTs k. pc = k+1 \\<and> ins!k = MI(Invoke mn pTs) \\<and> |
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
38 |
(mn,pTs) = sig0 \\<and> |
8011 | 39 |
(\\<exists>apTs D ST'. |
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
40 |
fst((phi C sig)!k) = (rev apTs) @ (Class D) # ST' \\<and> |
8011 | 41 |
length apTs = length pTs \\<and> |
42 |
(\\<exists>D' rT' maxl' ins'. |
|
8047 | 43 |
method (G,D) sig0 = Some(D',rT',(maxl',ins')) \\<and> |
8011 | 44 |
G \\<turnstile> rT0 \\<preceq> rT') \\<and> |
45 |
correct_frame G hp (tl ST, LT) maxl ins f \\<and> |
|
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
46 |
correct_frames G hp phi rT sig frs))))" |
8011 | 47 |
|
48 |
||
49 |
constdefs |
|
50 |
correct_state :: "[jvm_prog,prog_type,jvm_state] \\<Rightarrow> bool" |
|
8032 | 51 |
("_,_\\<turnstile>JVM _\\<surd>" [51,51] 50) |
8011 | 52 |
"correct_state G phi \\<equiv> \\<lambda>(xp,hp,frs). |
53 |
case xp of |
|
54 |
None \\<Rightarrow> (case frs of |
|
55 |
[] \\<Rightarrow> True |
|
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
56 |
| (f#fs) \\<Rightarrow> G\\<turnstile>h hp\\<surd> \\<and> |
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
57 |
(let (stk,loc,C,sig,pc) = f |
8011 | 58 |
in |
59 |
\\<exists>rT maxl ins. |
|
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
60 |
method (G,C) sig = Some(C,rT,(maxl,ins)) \\<and> |
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
61 |
correct_frame G hp ((phi C sig) ! pc) maxl ins f \\<and> |
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8034
diff
changeset
|
62 |
correct_frames G hp phi rT sig fs)) |
8011 | 63 |
| Some x \\<Rightarrow> True" |
64 |
||
65 |
end |