src/HOL/MicroJava/BV/BVSpec.thy
author kleing
Thu, 21 Feb 2002 09:54:08 +0100
changeset 12911 704713ca07ea
parent 12516 d09d0f160888
child 13006 51c5f3f11d16
permissions -rw-r--r--
new document
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/MicroJava/BV/BVSpec.thy
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     2
    ID:         $Id$
12516
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
     3
    Author:     Cornelia Pusch, Gerwin Klein
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     4
    Copyright   1999 Technische Universitaet Muenchen
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     5
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     6
*)
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     7
12911
704713ca07ea new document
kleing
parents: 12516
diff changeset
     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
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    10
theory BVSpec = Effect:
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    11
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    12
text {*
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    13
  This theory contains a specification of the BV. The specification
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    14
  describes correct typings of method bodies; it corresponds 
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    15
  to type \emph{checking}.
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    16
*}
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    17
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    18
constdefs
12516
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    19
  wt_instr :: "[instr,jvm_prog,ty,method_type,nat,p_count,
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    20
                exception_table,p_count] => bool"
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    21
  "wt_instr i G rT phi mxs max_pc et pc == 
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    22
  app i G mxs rT pc et (phi!pc) \<and>
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    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
12516
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    25
  wt_start :: "[jvm_prog,cname,ty list,nat,method_type] => bool"
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    26
  "wt_start G C pTs mxl phi == 
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    27
  G \<turnstile> Some ([],(OK (Class C))#((map OK pTs))@(replicate mxl Err)) <=' phi!0"
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    28
12516
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    29
  wt_method :: "[jvm_prog,cname,ty list,ty,nat,nat,instr list,
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    30
                 exception_table,method_type] => bool"
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    31
  "wt_method G C pTs rT mxs mxl ins et phi ==
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    32
  let max_pc = length ins in
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    33
  0 < max_pc \<and> wt_start G C pTs mxl phi \<and> 
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    34
  (\<forall>pc. pc<max_pc --> wt_instr (ins ! pc) G rT phi mxs max_pc et pc)"
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    35
12516
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    36
  wt_jvm_prog :: "[jvm_prog,prog_type] => bool"
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    37
  "wt_jvm_prog G phi ==
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    38
  wf_prog (\<lambda>G C (sig,rT,(maxs,maxl,b,et)).
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    39
           wt_method G C (snd sig) rT maxs maxl b et (phi C sig)) G"
9559
kleing
parents: 9549
diff changeset
    40
kleing
parents: 9549
diff changeset
    41
9549
40d64cb4f4e6 BV and LBV specified in terms of app and step functions
kleing
parents: 9376
diff changeset
    42
lemma wt_jvm_progD:
12516
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    43
  "wt_jvm_prog G phi ==> (\<exists>wt. wf_prog wt G)"
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    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
d790faef9c07 removed two intermediate comments
oheimb
parents: 10612
diff changeset
    46
lemma wt_jvm_prog_impl_wt_instr:
12516
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    47
  "[| wt_jvm_prog G phi; is_class G C;
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    48
      method (G,C) sig = Some (C,rT,maxs,maxl,ins,et); pc < length ins |] 
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    49
  ==> wt_instr (ins!pc) G rT (phi C sig) maxs (length ins) et pc";
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    50
  by (unfold wt_jvm_prog_def, drule method_wf_mdecl, 
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    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
d790faef9c07 removed two intermediate comments
oheimb
parents: 10612
diff changeset
    53
lemma wt_jvm_prog_impl_wt_start:
12516
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    54
  "[| wt_jvm_prog G phi; is_class G C;
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    55
      method (G,C) sig = Some (C,rT,maxs,maxl,ins,et) |] ==> 
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    56
  0 < (length ins) \<and> wt_start G C (snd sig) maxl (phi C sig)"
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    57
  by (unfold wt_jvm_prog_def, drule method_wf_mdecl, 
d09d0f160888 exceptions
kleing
parents: 11085
diff changeset
    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
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    60
end