src/HOL/MicroJava/BV/Altern.thy
author berghofe
Wed, 27 Nov 2002 17:11:38 +0100
changeset 13727 4ab8d49ab981
parent 13672 b95d12325b51
child 14045 a34d89ce6097
permissions -rw-r--r--
Fixed bug in consts_code section.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13672
b95d12325b51 Added compiler
streckem
parents:
diff changeset
     1
b95d12325b51 Added compiler
streckem
parents:
diff changeset
     2
theory Altern = BVSpec:
b95d12325b51 Added compiler
streckem
parents:
diff changeset
     3
b95d12325b51 Added compiler
streckem
parents:
diff changeset
     4
b95d12325b51 Added compiler
streckem
parents:
diff changeset
     5
constdefs
b95d12325b51 Added compiler
streckem
parents:
diff changeset
     6
  check_type :: "jvm_prog \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> state \<Rightarrow> bool"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
     7
  "check_type G mxs mxr s \<equiv> s \<in> states G mxs mxr"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
     8
b95d12325b51 Added compiler
streckem
parents:
diff changeset
     9
  wt_instr_altern :: "[instr,jvm_prog,ty,method_type,nat,nat,p_count,
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    10
                exception_table,p_count] \<Rightarrow> bool"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    11
  "wt_instr_altern i G rT phi mxs mxr max_pc et pc \<equiv>
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    12
  app i G mxs rT pc et (phi!pc) \<and>
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    13
  check_type G mxs mxr (OK (phi!pc)) \<and>
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    14
  (\<forall>(pc',s') \<in> set (eff i G pc et (phi!pc)). pc' < max_pc \<and> G \<turnstile> s' <=' phi!pc')"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    15
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    16
  wt_method_altern :: "[jvm_prog,cname,ty list,ty,nat,nat,instr list,
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    17
                 exception_table,method_type] \<Rightarrow> bool"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    18
  "wt_method_altern G C pTs rT mxs mxl ins et phi \<equiv>
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    19
  let max_pc = length ins in
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    20
  0 < max_pc \<and> 
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    21
  length phi = length ins \<and>
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    22
  check_bounded ins et \<and> 
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    23
  wt_start G C pTs mxl phi \<and>
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    24
  (\<forall>pc. pc<max_pc \<longrightarrow> wt_instr_altern (ins!pc) G rT phi mxs (1+length pTs+mxl) max_pc et pc)"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    25
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    26
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    27
lemma wt_method_wt_method_altern : 
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    28
  "wt_method G C pTs rT mxs mxl ins et phi \<longrightarrow> wt_method_altern G C pTs rT mxs mxl ins et phi"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    29
apply (simp add: wt_method_def wt_method_altern_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    30
apply (intro strip)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    31
apply clarify
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    32
apply (drule spec, drule mp, assumption)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    33
apply (simp add: check_types_def wt_instr_def wt_instr_altern_def check_type_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    34
apply (auto  intro: imageI)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    35
done
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    36
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    37
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    38
lemma check_type_check_types [rule_format]: 
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    39
  "(\<forall>pc. pc < length phi \<longrightarrow> check_type G mxs mxr (OK (phi ! pc)))
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    40
  \<longrightarrow> check_types G mxs mxr (map OK phi)"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    41
apply (induct phi)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    42
apply (simp add: check_types_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    43
apply (simp add: check_types_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    44
apply clarify
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    45
apply (frule_tac x=0 in spec)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    46
apply (simp add: check_type_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    47
apply auto
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    48
done
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    49
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    50
lemma wt_method_altern_wt_method [rule_format]: 
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    51
  "wt_method_altern G C pTs rT mxs mxl ins et phi \<longrightarrow> wt_method G C pTs rT mxs mxl ins et phi"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    52
apply (simp add: wt_method_def wt_method_altern_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    53
apply (intro strip)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    54
apply clarify
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    55
apply (rule conjI)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    56
  (* show check_types *)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    57
apply (rule check_type_check_types)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    58
apply (simp add: wt_instr_altern_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    59
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    60
  (* show wt_instr *)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    61
apply (intro strip)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    62
apply (drule spec, drule mp, assumption)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    63
apply (simp add: wt_instr_def wt_instr_altern_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    64
done
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    65
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    66
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    67
end