src/HOL/MicroJava/BV/Altern.thy
author kleing
Mon, 21 Jun 2004 10:25:57 +0200
changeset 14981 e73f8140af78
parent 14045 a34d89ce6097
child 16417 9bc16273c2d4
permissions -rw-r--r--
Merged in license change from Isabelle2004
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14045
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 13672
diff changeset
     1
(*  Title:      HOL/MicroJava/BV/Altern.thy
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 13672
diff changeset
     2
    ID:         $Id$
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 13672
diff changeset
     3
    Author:     Martin Strecker
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 13672
diff changeset
     4
*)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 13672
diff changeset
     5
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 13672
diff changeset
     6
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 13672
diff changeset
     7
(* Alternative definition of well-typing of bytecode, 
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 13672
diff changeset
     8
   used in compiler type correctness proof *)
a34d89ce6097 Introduced distinction wf_prog vs. ws_prog
streckem
parents: 13672
diff changeset
     9
13672
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    10
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    11
theory Altern = BVSpec:
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    12
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    13
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    14
constdefs
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    15
  check_type :: "jvm_prog \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> state \<Rightarrow> bool"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    16
  "check_type G mxs mxr s \<equiv> s \<in> states G mxs mxr"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    17
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    18
  wt_instr_altern :: "[instr,jvm_prog,ty,method_type,nat,nat,p_count,
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    19
                exception_table,p_count] \<Rightarrow> bool"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    20
  "wt_instr_altern i G rT phi mxs mxr max_pc et pc \<equiv>
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    21
  app i G mxs rT pc et (phi!pc) \<and>
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    22
  check_type G mxs mxr (OK (phi!pc)) \<and>
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    23
  (\<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
    24
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    25
  wt_method_altern :: "[jvm_prog,cname,ty list,ty,nat,nat,instr list,
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    26
                 exception_table,method_type] \<Rightarrow> bool"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    27
  "wt_method_altern G C pTs rT mxs mxl ins et phi \<equiv>
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    28
  let max_pc = length ins in
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    29
  0 < max_pc \<and> 
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    30
  length phi = length ins \<and>
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    31
  check_bounded ins et \<and> 
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    32
  wt_start G C pTs mxl phi \<and>
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    33
  (\<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
    34
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    35
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    36
lemma wt_method_wt_method_altern : 
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    37
  "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
    38
apply (simp add: wt_method_def wt_method_altern_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    39
apply (intro strip)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    40
apply clarify
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    41
apply (drule spec, drule mp, assumption)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    42
apply (simp add: check_types_def wt_instr_def wt_instr_altern_def check_type_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    43
apply (auto  intro: imageI)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    44
done
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    45
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    46
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    47
lemma check_type_check_types [rule_format]: 
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    48
  "(\<forall>pc. pc < length phi \<longrightarrow> check_type G mxs mxr (OK (phi ! pc)))
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    49
  \<longrightarrow> check_types G mxs mxr (map OK phi)"
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    50
apply (induct phi)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    51
apply (simp add: check_types_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    52
apply (simp add: check_types_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    53
apply clarify
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    54
apply (frule_tac x=0 in spec)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    55
apply (simp add: check_type_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    56
apply auto
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    57
done
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    58
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    59
lemma wt_method_altern_wt_method [rule_format]: 
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    60
  "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
    61
apply (simp add: wt_method_def wt_method_altern_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    62
apply (intro strip)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    63
apply clarify
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    64
apply (rule conjI)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    65
  (* show check_types *)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    66
apply (rule check_type_check_types)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    67
apply (simp add: wt_instr_altern_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    68
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    69
  (* show wt_instr *)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    70
apply (intro strip)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    71
apply (drule spec, drule mp, assumption)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    72
apply (simp add: wt_instr_def wt_instr_altern_def)
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    73
done
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    74
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    75
b95d12325b51 Added compiler
streckem
parents:
diff changeset
    76
end