src/HOL/MicroJava/BV/BVSpec.thy
author kleing
Wed, 09 Aug 2000 11:53:00 +0200
changeset 9559 1f99296758c2
parent 9549 40d64cb4f4e6
child 9757 1024a2d80ac0
permissions -rw-r--r--
tuned
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$
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     3
    Author:     Cornelia Pusch
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
Specification of bytecode verifier
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     7
*)
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
     8
9549
40d64cb4f4e6 BV and LBV specified in terms of app and step functions
kleing
parents: 9376
diff changeset
     9
theory BVSpec = Step :
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    10
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    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
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    15
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    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
3e5ddca613dd re-shaped and re-ordered conversion relations
oheimb
parents: 8011
diff changeset
    24
    G \\<turnstile> ([],(Some(Class C))#((map Some pTs))@(replicate mxl None)) <=s phi!0"
8011
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    25
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    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
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    29
	let max_pc = length ins
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    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
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    32
	(\\<forall>pc. pc<max_pc \\<longrightarrow> wt_instr (ins ! pc) G rT phi max_pc pc)"
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    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
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    35
"wt_jvm_prog G phi \\<equiv>
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    36
   wf_prog (\\<lambda>G C (sig,rT,maxl,b).
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    37
              wt_method G C (snd sig) rT maxl b (phi C sig)) G"
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    38
9559
kleing
parents: 9549
diff changeset
    39
kleing
parents: 9549
diff changeset
    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
d14c4e9e9c8e *** empty log message ***
nipkow
parents:
diff changeset
    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