src/HOL/MicroJava/BV/BVSpec.thy
author oheimb
Thu Dec 07 17:59:24 2000 +0100 (2000-12-07)
changeset 10629 d790faef9c07
parent 10612 779af7c58743
child 10638 17063aee1d86
permissions -rw-r--r--
removed two intermediate comments
nipkow@8011
     1
(*  Title:      HOL/MicroJava/BV/BVSpec.thy
nipkow@8011
     2
    ID:         $Id$
nipkow@8011
     3
    Author:     Cornelia Pusch
nipkow@8011
     4
    Copyright   1999 Technische Universitaet Muenchen
nipkow@8011
     5
nipkow@8011
     6
*)
nipkow@8011
     7
kleing@9757
     8
header "The Bytecode Verifier"
kleing@9757
     9
kleing@9757
    10
theory BVSpec = Step:
nipkow@8011
    11
nipkow@8011
    12
constdefs
kleing@10592
    13
wt_instr :: "[instr,jvm_prog,ty,method_type,nat,p_count,p_count] => bool"
kleing@10592
    14
"wt_instr i G rT phi mxs max_pc pc == 
kleing@10592
    15
    app i G mxs rT (phi!pc) \<and>
kleing@9757
    16
   (\<forall> pc' \<in> set (succs i pc). pc' < max_pc \<and> (G \<turnstile> step i G (phi!pc) <=' phi!pc'))"
kleing@9549
    17
kleing@10042
    18
wt_start :: "[jvm_prog,cname,ty list,nat,method_type] => bool"
kleing@10042
    19
"wt_start G C pTs mxl phi == 
kleing@10496
    20
    G \<turnstile> Some ([],(OK (Class C))#((map OK pTs))@(replicate mxl Err)) <=' phi!0"
nipkow@8011
    21
nipkow@8011
    22
kleing@10592
    23
wt_method :: "[jvm_prog,cname,ty list,ty,nat,nat,instr list,method_type] => bool"
kleing@10592
    24
"wt_method G C pTs rT mxs mxl ins phi ==
nipkow@8011
    25
	let max_pc = length ins
nipkow@8011
    26
        in
kleing@9757
    27
	0 < max_pc \<and> wt_start G C pTs mxl phi \<and> 
kleing@10592
    28
	(\<forall>pc. pc<max_pc --> wt_instr (ins ! pc) G rT phi mxs max_pc pc)"
nipkow@8011
    29
kleing@10042
    30
wt_jvm_prog :: "[jvm_prog,prog_type] => bool"
kleing@10042
    31
"wt_jvm_prog G phi ==
kleing@10592
    32
   wf_prog (\<lambda>G C (sig,rT,(maxs,maxl,b)).
kleing@10592
    33
              wt_method G C (snd sig) rT maxs maxl b (phi C sig)) G"
nipkow@8011
    34
kleing@9559
    35
kleing@9559
    36
kleing@9549
    37
lemma wt_jvm_progD:
kleing@10042
    38
"wt_jvm_prog G phi ==> (\<exists>wt. wf_prog wt G)"
kleing@9549
    39
by (unfold wt_jvm_prog_def, blast)
kleing@9549
    40
oheimb@10629
    41
lemma wt_jvm_prog_impl_wt_instr:
oheimb@10612
    42
"[| wt_jvm_prog G phi; is_class G C;
oheimb@10612
    43
    method (G,C) sig = Some (C,rT,maxs,maxl,ins); pc < length ins |] 
kleing@10592
    44
 ==> wt_instr (ins!pc) G rT (phi C sig) maxs (length ins) pc";
kleing@9549
    45
by (unfold wt_jvm_prog_def, drule method_wf_mdecl, 
oheimb@10612
    46
    simp, simp, simp add: wf_mdecl_def wt_method_def)
kleing@9549
    47
oheimb@10629
    48
lemma wt_jvm_prog_impl_wt_start:
oheimb@10612
    49
"[| wt_jvm_prog G phi; is_class G C;
oheimb@10612
    50
    method (G,C) sig = Some (C,rT,maxs,maxl,ins) |] ==> 
kleing@9757
    51
 0 < (length ins) \<and> wt_start G C (snd sig) maxl (phi C sig)"
kleing@9549
    52
by (unfold wt_jvm_prog_def, drule method_wf_mdecl, 
oheimb@10612
    53
    simp, simp, simp add: wf_mdecl_def wt_method_def)
kleing@9549
    54
kleing@10593
    55
text {* for most instructions wt\_instr collapses: *}
kleing@9757
    56
lemma  
kleing@10592
    57
"succs i pc = [pc+1] ==> wt_instr i G rT phi mxs max_pc pc = 
kleing@10592
    58
 (app i G mxs rT (phi!pc) \<and> pc+1 < max_pc \<and> (G \<turnstile> step i G (phi!pc) <=' phi!(pc+1)))"
kleing@9549
    59
by (simp add: wt_instr_def) 
kleing@9549
    60
nipkow@8011
    61
end
kleing@9549
    62
kleing@9549
    63