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