src/HOL/MicroJava/Comp/CorrCompTp.thy
author kleing
Thu, 24 Oct 2002 12:06:43 +0200
changeset 13676 b1915d3e571d
parent 13673 2950128b8206
child 13679 2ebad1cb045f
permissions -rw-r--r--
fixed latex error
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     1
(*  Title:      HOL/MicroJava/Comp/CorrCompTp.thy
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     2
    ID:         $Id$
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     3
    Author:     Martin Strecker
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     4
    Copyright   GPL 2002
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     5
*)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     6
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     7
theory CorrCompTp =  LemmasComp + JVM + TypeInf + NatCanonify + Altern:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     8
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
     9
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    10
declare split_paired_All [simp del]
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    11
declare split_paired_Ex [simp del]
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    12
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    13
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    14
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    15
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    16
constdefs     
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    17
   inited_LT :: "[cname, ty list, (vname \<times> ty) list] \<Rightarrow> locvars_type"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    18
  "inited_LT C pTs lvars == (OK (Class C))#((map OK pTs))@(map (Fun.comp OK snd) lvars)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    19
   is_inited_LT :: "[cname, ty list, (vname \<times> ty) list, locvars_type] \<Rightarrow> bool"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    20
  "is_inited_LT C pTs lvars LT == (LT = (inited_LT C pTs lvars))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    21
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    22
  local_env :: "[java_mb prog, cname, sig, vname list,(vname \<times> ty) list] \<Rightarrow> java_mb env"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    23
  "local_env G C S pns lvars == 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    24
     let (mn, pTs) = S in (G,map_of lvars(pns[\<mapsto>]pTs)(This\<mapsto>Class C))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    25
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    26
lemma local_env_fst [simp]: "fst (local_env G C S pns lvars) = G"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    27
by (simp add: local_env_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    28
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    29
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    30
lemma wt_class_expr_is_class: "\<lbrakk> wf_prog wf_mb G; E \<turnstile> expr :: Class cname;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    31
  E = local_env G C (mn, pTs) pns lvars\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    32
  \<Longrightarrow> is_class G cname "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    33
apply (subgoal_tac "((fst E), (snd E)) \<turnstile> expr :: Class cname")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    34
apply (frule ty_expr_is_type) apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    35
apply simp apply (simp (no_asm_use))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    36
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    37
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    38
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    39
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    40
(********************************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    41
(**** Stuff about index ****)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    42
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    43
lemma local_env_snd: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    44
  snd (local_env G C (mn, pTs) pns lvars) = map_of lvars(pns[\<mapsto>]pTs)(This\<mapsto>Class C)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    45
by (simp add: local_env_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    46
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    47
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    48
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    49
lemma index_in_bounds: " length pns = length pTs \<Longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    50
  snd (local_env G C (mn, pTs) pns lvars) vname = Some T
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    51
       \<Longrightarrow> index (pns, lvars, blk, res) vname < length (inited_LT C pTs lvars)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    52
apply (simp add: local_env_snd index_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    53
apply (case_tac "vname = This")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    54
apply (simp add: inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    55
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    56
apply (drule map_of_upds_SomeD)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    57
apply (drule length_takeWhile)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    58
apply (simp add: inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    59
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    60
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    61
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    62
lemma map_upds_append [rule_format (no_asm)]: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    63
  "\<forall> x1s m. (length k1s = length x1s 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    64
  \<longrightarrow> m(k1s[\<mapsto>]x1s)(k2s[\<mapsto>]x2s) = m ((k1s@k2s)[\<mapsto>](x1s@x2s)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    65
apply (induct k1s)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    66
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    67
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    68
apply (subgoal_tac "\<exists> x xr. x1s = x # xr")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    69
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    70
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    71
  (* subgoal *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    72
apply (case_tac x1s)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    73
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    74
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    75
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    76
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    77
lemma map_of_append [rule_format]: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    78
  "\<forall> ys. (map_of ((rev xs) @ ys) = (map_of ys) ((map fst xs) [\<mapsto>] (map snd xs)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    79
apply (induct xs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    80
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    81
apply (rule allI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    82
apply (drule_tac x="a # ys" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    83
apply (simp only: rev.simps append_assoc append_Cons append_Nil
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    84
  map.simps map_of.simps map_upds.simps hd.simps tl.simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    85
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    86
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    87
lemma map_of_as_map_upds: "map_of (rev xs) = empty ((map fst xs) [\<mapsto>] (map snd xs))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    88
by (rule map_of_append [of _ "[]", simplified])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    89
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    90
lemma map_of_rev: "unique xs \<Longrightarrow> map_of (rev xs) = map_of xs"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    91
apply (induct xs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    92
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    93
apply (simp add: unique_def map_of_append map_of_as_map_upds [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    94
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    95
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    96
lemma map_upds_rev [rule_format]: "\<forall> xs. (distinct ks \<longrightarrow> length ks = length xs 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    97
  \<longrightarrow> m (rev ks [\<mapsto>] rev xs) = m (ks [\<mapsto>] xs))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    98
apply (induct ks)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
    99
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   100
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   101
apply (subgoal_tac "\<exists> x xr. xs = x # xr")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   102
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   103
apply (drule_tac x=xr in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   104
apply (simp add: map_upds_append [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   105
  (* subgoal *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   106
apply (case_tac xs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   107
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   108
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   109
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   110
lemma map_upds_takeWhile [rule_format]:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   111
  "\<forall> ks. (empty(rev ks[\<mapsto>]rev xs)) k = Some x \<longrightarrow> length ks = length xs \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   112
    xs ! length (takeWhile (\<lambda>z. z \<noteq> k) ks) = x"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   113
apply (induct xs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   114
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   115
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   116
apply (subgoal_tac "\<exists> k' kr. ks = k' # kr")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   117
apply (clarify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   118
apply (drule_tac x=kr in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   119
apply (simp only: rev.simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   120
apply (subgoal_tac "(empty(rev kr @ [k'][\<mapsto>]rev list @ [a])) = empty (rev kr[\<mapsto>]rev list)([k'][\<mapsto>][a])")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   121
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   122
apply (case_tac "k' = k")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   123
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   124
apply simp 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   125
apply (case_tac "k = k'")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   126
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   127
apply (simp add: empty_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   128
apply (simp add: map_upds_append [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   129
apply (case_tac ks)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   130
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   131
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   132
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   133
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   134
lemma local_env_inited_LT: "\<lbrakk> snd (local_env G C (mn, pTs) pns lvars) vname = Some T;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   135
  length pns = length pTs; distinct pns; unique lvars \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   136
  \<Longrightarrow> (inited_LT C pTs lvars ! index (pns, lvars, blk, res) vname) = OK T"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   137
apply (simp add: local_env_snd index_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   138
apply (case_tac "vname = This")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   139
apply (simp add: inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   140
apply (simp add: inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   141
apply (simp (no_asm_simp) only: map_compose map_append [THEN sym] map.simps [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   142
apply (subgoal_tac "length (takeWhile (\<lambda>z. z \<noteq> vname) (pns @ map fst lvars)) < length (pTs @ map snd lvars)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   143
apply (simp (no_asm_simp) only: List.nth_map ok_val.simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   144
apply (subgoal_tac "map_of lvars = map_of (map (\<lambda> p. (fst p, snd p)) lvars)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   145
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   146
apply (subgoal_tac "distinct (map fst lvars)") 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   147
apply (frule_tac g=snd in AuxLemmas.map_of_map_as_map_upd)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   148
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   149
apply (simp add: map_upds_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   150
apply (frule map_upds_SomeD)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   151
apply (rule map_upds_takeWhile)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   152
apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   153
apply (simp add: map_upds_append [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   154
apply (simp add: map_upds_rev)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   155
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   156
  (* show length (pns @ map fst lvars) = length (pTs @ map snd lvars) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   157
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   158
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   159
  (* show distinct (map fst lvars) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   160
apply (simp only: unique_def Fun.comp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   161
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   162
  (* show map_of lvars = map_of (map (\<lambda>p. (fst p, snd p)) lvars) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   163
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   164
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   165
  (* show length (takeWhile (\<lambda>z. z \<noteq> vname) (pns @ map fst lvars)) < length (pTs @ map snd lvars) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   166
apply (drule map_of_upds_SomeD)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   167
apply (drule length_takeWhile)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   168
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   169
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   170
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   171
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   172
lemma inited_LT_at_index_no_err: " i < length (inited_LT C pTs lvars)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   173
  \<Longrightarrow> inited_LT C pTs lvars ! i \<noteq> Err"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   174
apply (simp only: inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   175
apply (simp only: map_compose map_append [THEN sym] map.simps [THEN sym] length_map)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   176
apply (simp only: nth_map)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   177
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   178
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   179
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   180
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   181
lemma sup_loc_update_index: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   182
  \<lbrakk> G \<turnstile> T \<preceq> T'; is_type G T'; length pns = length pTs; distinct pns; unique lvars;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   183
  snd (local_env G C (mn, pTs) pns lvars) vname = Some T' \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   184
  \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   185
  comp G \<turnstile> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   186
  inited_LT C pTs lvars [index (pns, lvars, blk, res) vname := OK T] <=l 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   187
  inited_LT C pTs lvars"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   188
apply (subgoal_tac " index (pns, lvars, blk, res) vname < length (inited_LT C pTs lvars)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   189
apply (frule_tac blk=blk and res=res in local_env_inited_LT, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   190
apply (rule sup_loc_trans)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   191
apply (rule_tac b="OK T'" in sup_loc_update)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   192
apply (simp add: comp_widen) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   193
apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   194
apply (rule sup_loc_refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   195
apply (simp add: list_update_same_conv [THEN iffD2])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   196
  (* subgoal *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   197
apply (rule index_in_bounds)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   198
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   199
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   200
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   201
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   202
(********************************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   203
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   204
(* Preservation of ST and LT by compTpExpr / compTpStmt *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   205
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   206
lemma sttp_of_comb_nil [simp]: "sttp_of (comb_nil sttp) = sttp"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   207
by (simp add: comb_nil_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   208
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   209
lemma mt_of_comb_nil [simp]: "mt_of (comb_nil sttp) = []"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   210
by (simp add: comb_nil_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   211
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   212
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   213
lemma sttp_of_comb [simp]: "sttp_of ((f1 \<box> f2) sttp) = sttp_of (f2 (sttp_of (f1 sttp)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   214
apply (case_tac "f1 sttp")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   215
apply (case_tac "(f2 (sttp_of (f1 sttp)))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   216
apply (simp add: comb_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   217
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   218
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   219
lemma mt_of_comb: "(mt_of ((f1 \<box> f2) sttp)) = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   220
  (mt_of (f1 sttp)) @ (mt_of (f2 (sttp_of (f1 sttp))))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   221
by (simp add: comb_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   222
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   223
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   224
lemma mt_of_comb_length [simp]: "\<lbrakk> n1 = length (mt_of (f1 sttp)); n1 \<le> n \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   225
  \<Longrightarrow> (mt_of ((f1 \<box> f2) sttp) ! n) = (mt_of (f2 (sttp_of (f1 sttp))) ! (n - n1))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   226
by (simp add: comb_def nth_append split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   227
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   228
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   229
lemma compTpExpr_Exprs_LT_ST: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   230
  \<lbrakk>jmb = (pns, lvars, blk, res); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   231
  wf_prog wf_java_mdecl G;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   232
  wf_java_mdecl G C ((mn, pTs), rT, jmb);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   233
  E = local_env G C (mn, pTs) pns lvars \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   234
 \<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   235
  (\<forall> ST LT T. 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   236
  E \<turnstile> ex :: T \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   237
  is_inited_LT C pTs lvars LT \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   238
  sttp_of (compTpExpr jmb G ex (ST, LT)) = (T # ST, LT))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   239
 \<and>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   240
 (\<forall> ST LT Ts. 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   241
  E \<turnstile> exs [::] Ts \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   242
  is_inited_LT C pTs lvars LT \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   243
  sttp_of (compTpExprs jmb G exs (ST, LT)) = ((rev Ts) @ ST, LT))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   244
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   245
apply (rule expr.induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   246
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   247
(* expresssions *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   248
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   249
(* NewC *) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   250
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   251
apply (drule NewC_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   252
apply (simp add: pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   253
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   254
(* Cast *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   255
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   256
apply (drule Cast_invers, clarify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   257
apply ((drule_tac x=ST in spec), (drule spec)+, (drule mp, assumption)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   258
apply (simp add: replST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   259
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   260
(* Lit *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   261
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   262
apply (drule Lit_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   263
apply (simp add: pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   264
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   265
(* BinOp *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   266
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   267
apply (drule BinOp_invers, clarify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   268
apply (drule_tac x=ST in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   269
apply (drule_tac x="Ta # ST" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   270
apply ((drule spec)+, (drule mp, assumption)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   271
  apply (case_tac binop)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   272
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   273
    apply (simp (no_asm_simp) add: popST_def pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   274
  apply (simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   275
    apply (simp (no_asm_simp) add: replST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   276
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   277
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   278
(* LAcc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   279
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   280
apply (drule LAcc_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   281
apply (simp add: pushST_def is_inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   282
apply (simp add: wf_prog_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   283
apply (frule wf_java_mdecl_disjoint_varnames) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   284
  apply (simp add: disjoint_varnames_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   285
apply (frule wf_java_mdecl_length_pTs_pns)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   286
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   287
apply (simp (no_asm_simp) add: local_env_inited_LT)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   288
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   289
(* LAss *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   290
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   291
apply (drule LAss_invers, clarify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   292
apply (drule LAcc_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   293
apply ((drule_tac x=ST in spec), (drule spec)+, (drule mp, assumption)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   294
apply (simp add: popST_def dupST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   295
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   296
(* FAcc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   297
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   298
apply (drule FAcc_invers, clarify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   299
apply ((drule_tac x=ST in spec), (drule spec)+, (drule mp, assumption)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   300
apply (simp add: replST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   301
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   302
  (* show   snd (the (field (G, cname) vname)) = T *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   303
  apply (subgoal_tac "is_class G Ca")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   304
  apply (subgoal_tac "is_class G cname \<and> field (G, cname) vname = Some (cname, T)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   305
  apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   306
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   307
  (* show is_class G cname \<and> field (G, cname) vname = Some (cname, T) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   308
  apply (rule field_in_fd) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   309
  (* show is_class G Ca *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   310
  apply (rule wt_class_expr_is_class, assumption+, rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   311
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   312
(* FAss *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   313
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   314
apply (drule FAss_invers, clarify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   315
apply (drule FAcc_invers, clarify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   316
apply (drule_tac x=ST in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   317
apply (drule_tac x="Class Ca # ST" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   318
apply ((drule spec)+, (drule mp, assumption)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   319
apply (simp add: popST_def dup_x1ST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   320
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   321
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   322
(* Call *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   323
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   324
apply (drule Call_invers, clarify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   325
apply (drule_tac x=ST in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   326
apply (drule_tac x="Class cname # ST" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   327
apply ((drule spec)+, (drule mp, assumption)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   328
apply (simp add: replST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   329
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   330
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   331
(* expression lists *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   332
(* nil *) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   333
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   334
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   335
apply (drule Nil_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   336
apply (simp add: comb_nil_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   337
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   338
(* cons *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   339
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   340
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   341
apply (drule Cons_invers, clarify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   342
apply (drule_tac x=ST in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   343
apply (drule_tac x="T # ST" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   344
apply ((drule spec)+, (drule mp, assumption)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   345
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   346
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   347
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   348
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   349
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   350
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   351
lemmas compTpExpr_LT_ST [rule_format (no_asm)] = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   352
  compTpExpr_Exprs_LT_ST [THEN conjunct1]
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   353
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   354
lemmas compTpExprs_LT_ST [rule_format (no_asm)] = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   355
  compTpExpr_Exprs_LT_ST [THEN conjunct2]
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   356
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   357
lemma compTpStmt_LT_ST [rule_format (no_asm)]: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   358
  \<lbrakk> jmb = (pns,lvars,blk,res); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   359
  wf_prog wf_java_mdecl G;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   360
  wf_java_mdecl G C ((mn, pTs), rT, jmb);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   361
  E = (local_env G C (mn, pTs) pns lvars)\<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   362
\<Longrightarrow> (\<forall> ST LT.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   363
  E \<turnstile> s\<surd> \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   364
  (is_inited_LT C pTs lvars LT)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   365
\<longrightarrow> sttp_of (compTpStmt jmb G s (ST, LT)) = (ST, LT))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   366
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   367
apply (rule stmt.induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   368
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   369
(* Skip *) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   370
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   371
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   372
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   373
(* Expr *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   374
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   375
apply (drule Expr_invers, erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   376
apply (simp (no_asm_simp) add: compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   377
apply (frule_tac ST=ST in compTpExpr_LT_ST, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   378
apply (simp add: popST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   379
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   380
(* Comp *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   381
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   382
apply (drule Comp_invers, clarify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   383
apply (simp (no_asm_use))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   384
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   385
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   386
(* Cond *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   387
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   388
apply (drule Cond_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   389
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   390
apply (drule_tac x=ST in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   391
apply (drule_tac x=ST in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   392
apply (drule spec)+ apply (drule mp, assumption)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   393
apply (drule_tac ST="PrimT Boolean # ST" in compTpExpr_LT_ST, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   394
apply (simp add: popST_def pushST_def nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   395
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   396
(* Loop *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   397
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   398
apply (drule Loop_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   399
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   400
apply (drule_tac x=ST in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   401
apply (drule spec)+ apply (drule mp, assumption)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   402
apply (drule_tac ST="PrimT Boolean # ST" in compTpExpr_LT_ST, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   403
apply (simp add: popST_def pushST_def nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   404
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   405
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   406
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   407
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   408
lemma compTpInit_LT_ST: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   409
  sttp_of (compTpInit jmb (vn,ty) (ST, LT)) = (ST, LT[(index jmb vn):= OK ty])"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   410
by (simp add: compTpInit_def storeST_def pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   411
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   412
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   413
lemma compTpInitLvars_LT_ST_aux [rule_format (no_asm)]:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   414
  "\<forall> pre lvars_pre lvars0.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   415
  jmb = (pns,lvars0,blk,res) \<and>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   416
  lvars0 = (lvars_pre @ lvars) \<and>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   417
  (length pns) + (length lvars_pre) + 1 = length pre \<and>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   418
  disjoint_varnames pns (lvars_pre @ lvars)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   419
  \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   420
sttp_of (compTpInitLvars jmb lvars (ST, pre @ replicate (length lvars) Err))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   421
    = (ST, pre @ map (Fun.comp OK snd) lvars)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   422
apply (induct lvars)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   423
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   424
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   425
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   426
apply (subgoal_tac "\<exists> vn ty. a = (vn, ty)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   427
  prefer 2 apply (simp (no_asm_simp)) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   428
  apply ((erule exE)+, simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   429
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   430
apply (drule_tac x="pre @ [OK ty]" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   431
apply (drule_tac x="lvars_pre @ [a]" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   432
apply (drule_tac x="lvars0" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   433
apply (simp add: compTpInit_LT_ST index_of_var2)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   434
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   435
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   436
lemma compTpInitLvars_LT_ST: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   437
  "\<lbrakk> jmb = (pns, lvars, blk, res); wf_java_mdecl G C ((mn, pTs), rT, jmb) \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   438
\<Longrightarrow>(sttp_of (compTpInitLvars jmb lvars (ST, start_LT C pTs (length lvars))))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   439
  = (ST, inited_LT C pTs lvars)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   440
apply (simp add: start_LT_def inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   441
apply (simp only: append_Cons [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   442
apply (rule compTpInitLvars_LT_ST_aux)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   443
apply (auto dest: wf_java_mdecl_length_pTs_pns wf_java_mdecl_disjoint_varnames)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   444
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   445
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   446
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   447
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   448
(********************************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   449
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   450
lemma max_of_list_elem: "x \<in> set xs \<Longrightarrow> x \<le> (max_of_list xs)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   451
by (induct xs, auto intro: le_maxI1 simp: le_max_iff_disj max_of_list_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   452
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   453
lemma max_of_list_sublist: "set xs \<subseteq> set ys 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   454
  \<Longrightarrow> (max_of_list xs) \<le> (max_of_list ys)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   455
by (induct xs, auto dest: max_of_list_elem simp: max_of_list_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   456
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   457
lemma max_of_list_append [simp]:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   458
  "max_of_list (xs @ ys) = max (max_of_list xs) (max_of_list ys)" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   459
apply (simp add: max_of_list_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   460
apply (induct xs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   461
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   462
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   463
apply arith
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   464
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   465
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   466
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   467
lemma app_mono_mxs: "\<lbrakk> app i G mxs rT pc et s; mxs \<le> mxs' \<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   468
  \<Longrightarrow> app i G mxs' rT pc et s"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   469
apply (case_tac s)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   470
apply (simp add: app_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   471
apply (case_tac i)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   472
apply (auto intro: less_trans)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   473
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   474
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   475
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   476
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   477
lemma err_mono [simp]: "A \<subseteq> B \<Longrightarrow> err A \<subseteq> err B"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   478
by (auto simp: err_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   479
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   480
lemma opt_mono [simp]: "A \<subseteq> B \<Longrightarrow> opt A \<subseteq> opt B"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   481
by (auto simp: opt_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   482
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   483
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   484
lemma states_mono: "\<lbrakk> mxs \<le> mxs' \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   485
  \<Longrightarrow> states G mxs mxr \<subseteq> states G mxs' mxr"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   486
apply (simp add: states_def JVMType.sl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   487
apply (simp add: Product.esl_def stk_esl_def reg_sl_def upto_esl_def Listn.sl_def Err.sl_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   488
  JType.esl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   489
apply (simp add: Err.esl_def Err.le_def Listn.le_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   490
apply (simp add: Product.le_def Product.sup_def Err.sup_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   491
apply (simp add: Opt.esl_def Listn.sup_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   492
apply (rule err_mono)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   493
apply (rule opt_mono)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   494
apply (rule Sigma_mono)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   495
apply (rule Union_mono)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   496
apply auto 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   497
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   498
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   499
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   500
lemma check_type_mono: "\<lbrakk> check_type G mxs mxr s; mxs \<le> mxs' \<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   501
  \<Longrightarrow> check_type G mxs' mxr s"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   502
apply (simp add: check_type_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   503
apply (frule_tac G=G and mxr=mxr in states_mono)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   504
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   505
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   506
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   507
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   508
  (* wt is preserved when adding instructions/state-types at the end *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   509
lemma wt_instr_prefix: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   510
 \<lbrakk> wt_instr_altern (bc ! pc) cG rT mt mxs mxr max_pc et pc; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   511
  bc' = bc @ bc_post; mt' = mt @ mt_post; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   512
  mxs \<le> mxs'; max_pc \<le> max_pc'; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   513
  pc < length bc; pc < length mt; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   514
  max_pc = (length mt)\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   515
\<Longrightarrow> wt_instr_altern (bc' ! pc) cG rT mt' mxs' mxr max_pc' et pc"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   516
apply (simp add: wt_instr_altern_def nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   517
apply (auto intro: app_mono_mxs check_type_mono)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   518
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   519
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   520
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   521
(************************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   522
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   523
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   524
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   525
lemma pc_succs_shift: "pc'\<in>set (succs i (pc'' + n))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   526
 \<Longrightarrow> ((pc' - n) \<in>set (succs i pc''))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   527
apply (induct i)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   528
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   529
  (* case Goto *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   530
apply (simp only: nat_canonify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   531
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   532
  (* case Ifcmpeq *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   533
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   534
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   535
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   536
apply (simp only: nat_canonify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   537
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   538
  (* case Throw *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   539
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   540
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   541
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   542
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   543
lemma pc_succs_le: "\<lbrakk> pc' \<in> set (succs i (pc'' + n));   
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   544
  \<forall> b. ((i = (Goto b) \<or> i=(Ifcmpeq b)) \<longrightarrow> 0 \<le> (int pc'' + b)) \<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   545
  \<Longrightarrow> n \<le> pc'"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   546
apply (induct i)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   547
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   548
  (* case Goto *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   549
apply (simp only: nat_canonify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   550
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   551
  (* case Ifcmpeq *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   552
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   553
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   554
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   555
apply (simp only: nat_canonify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   556
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   557
  (* case Throw *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   558
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   559
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   560
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   561
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   562
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   563
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   564
constdefs
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   565
  offset_xcentry :: "[nat, exception_entry] \<Rightarrow> exception_entry"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   566
  "offset_xcentry == 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   567
      \<lambda> n (start_pc, end_pc, handler_pc, catch_type).
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   568
          (start_pc + n, end_pc + n, handler_pc + n, catch_type)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   569
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   570
  offset_xctable :: "[nat, exception_table] \<Rightarrow> exception_table"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   571
  "offset_xctable n == (map (offset_xcentry n))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   572
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   573
lemma match_xcentry_offset [simp]: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   574
  match_exception_entry G cn (pc + n) (offset_xcentry n ee) = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   575
  match_exception_entry G cn pc ee"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   576
by (simp add: match_exception_entry_def offset_xcentry_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   577
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   578
lemma match_xctable_offset: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   579
  (match_exception_table G cn (pc + n) (offset_xctable n et)) =
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   580
  (option_map (\<lambda> pc'. pc' + n) (match_exception_table G cn pc et))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   581
apply (induct et)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   582
apply (simp add: offset_xctable_def)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   583
apply (case_tac "match_exception_entry G cn pc a")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   584
apply (simp add: offset_xcentry_def split_beta)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   585
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   586
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   587
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   588
lemma match_offset [simp]: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   589
  match G cn (pc + n) (offset_xctable n et) = match G cn pc et"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   590
apply (induct et)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   591
apply (simp add: offset_xctable_def)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   592
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   593
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   594
lemma match_any_offset [simp]: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   595
  match_any G (pc + n) (offset_xctable n et) = match_any G pc et"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   596
apply (induct et)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   597
apply (simp add: offset_xctable_def offset_xcentry_def split_beta)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   598
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   599
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   600
lemma app_mono_pc: "\<lbrakk> app i G mxs rT pc et s; pc'= pc + n \<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   601
  \<Longrightarrow> app i G mxs rT pc' (offset_xctable n et) s"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   602
apply (case_tac s)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   603
apply (simp add: app_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   604
apply (case_tac i)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   605
apply (auto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   606
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   607
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   608
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   609
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   610
  (* Currently: empty exception_table *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   611
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   612
syntax
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   613
  empty_et :: exception_table
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   614
translations
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   615
  "empty_et" => "[]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   616
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   617
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   618
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   619
  (* move into Effect.thy *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   620
lemma xcpt_names_Nil [simp]: "(xcpt_names (i, G, pc, [])) = []"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   621
by (induct i, simp_all)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   622
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   623
lemma xcpt_eff_Nil [simp]: "(xcpt_eff i G pc s []) = []"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   624
by (simp add: xcpt_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   625
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   626
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   627
lemma app_jumps_lem: "\<lbrakk> app i cG mxs rT pc empty_et s; s=(Some st) \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   628
  \<Longrightarrow>  \<forall> b. ((i = (Goto b) \<or> i=(Ifcmpeq b)) \<longrightarrow> 0 \<le> (int pc + b))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   629
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   630
apply (induct i)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   631
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   632
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   633
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   634
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   635
(* wt is preserved when adding instructions/state-types to the front *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   636
lemma wt_instr_offset: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   637
 \<lbrakk> \<forall> pc'' < length mt. 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   638
    wt_instr_altern ((bc@bc_post) ! pc'') cG rT (mt@mt_post) mxs mxr max_pc empty_et pc''; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   639
  bc' = bc_pre @ bc @ bc_post; mt' = mt_pre @ mt @ mt_post; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   640
  length bc_pre = length mt_pre; length bc = length mt;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   641
  length mt_pre \<le> pc; pc < length (mt_pre @ mt); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   642
  mxs \<le> mxs'; max_pc + length mt_pre \<le> max_pc' \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   643
\<Longrightarrow> wt_instr_altern (bc' ! pc) cG rT mt' mxs' mxr max_pc' empty_et pc"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   644
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   645
apply (simp add: wt_instr_altern_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   646
apply (subgoal_tac "\<exists> pc''. pc = pc'' + length mt_pre", erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   647
prefer 2 apply (rule_tac x="pc - length mt_pre" in exI, arith)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   648
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   649
apply (drule_tac x=pc'' in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   650
apply (drule mp) apply arith	(* show pc'' < length mt *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   651
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   652
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   653
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   654
  (* app *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   655
  apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   656
  apply (rule app_mono_mxs)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   657
  apply (frule app_mono_pc) apply (rule HOL.refl) apply (simp add: offset_xctable_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   658
  apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   659
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   660
  (* check_type *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   661
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   662
apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   663
apply (rule  check_type_mono) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   664
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   665
  (* ..eff.. *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   666
apply (intro ballI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   667
apply (subgoal_tac "\<exists> pc' s'. x = (pc', s')", (erule exE)+, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   668
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   669
apply (case_tac s')
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   670
  (* s' = None *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   671
apply (simp add: eff_def nth_append norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   672
apply (frule_tac x="(pc', None)" and  f=fst and b=pc' in rev_image_eqI) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   673
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   674
  apply (simp only: fst_conv image_compose [THEN sym] Fun.comp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   675
  apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   676
  apply (frule pc_succs_shift)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   677
apply (drule bspec, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   678
apply arith
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   679
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   680
  (* s' = Some a *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   681
apply (drule_tac x="(pc' - length mt_pre, s')" in bspec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   682
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   683
  (* show  (pc' - length mt_pre, s') \<in> set (eff \<dots>) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   684
apply (simp add: eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   685
    (* norm_eff *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   686
  apply (clarsimp simp: nth_append pc_succs_shift)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   687
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   688
  (* show P x of bspec *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   689
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   690
  apply (subgoal_tac "length mt_pre \<le> pc'")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   691
  apply (simp add: nth_append) apply arith
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   692
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   693
  (* subgoals *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   694
apply (simp add: eff_def xcpt_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   695
apply (clarsimp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   696
apply (rule pc_succs_le) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   697
apply (subgoal_tac "\<exists> st. mt ! pc'' = Some st", erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   698
 apply (rule_tac s="Some st" and st=st and cG=cG and mxs=mxs and rT=rT
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   699
        in app_jumps_lem)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   700
  apply (simp add: nth_append)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   701
    (* subgoal \<exists> st. mt ! pc'' = Some st *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   702
  apply (simp add: norm_eff_def option_map_def nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   703
  apply (case_tac "mt ! pc''")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   704
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   705
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   706
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   707
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   708
(**********************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   709
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   710
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   711
constdefs
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   712
  start_sttp_resp_cons :: "[state_type \<Rightarrow> method_type \<times> state_type] \<Rightarrow> bool"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   713
  "start_sttp_resp_cons f == 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   714
     (\<forall> sttp. let (mt', sttp') = (f sttp) in (\<exists>mt'_rest. mt' = Some sttp # mt'_rest))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   715
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   716
  start_sttp_resp :: "[state_type \<Rightarrow> method_type \<times> state_type] \<Rightarrow> bool"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   717
  "start_sttp_resp f == (f = comb_nil) \<or> (start_sttp_resp_cons f)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   718
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   719
lemma start_sttp_resp_comb_nil [simp]: "start_sttp_resp comb_nil"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   720
by (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   721
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   722
lemma start_sttp_resp_cons_comb_cons [simp]: "start_sttp_resp_cons f 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   723
  \<Longrightarrow> start_sttp_resp_cons (f \<box> f')"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   724
apply (simp add: start_sttp_resp_cons_def comb_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   725
apply (rule allI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   726
apply (drule_tac x=sttp in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   727
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   728
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   729
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   730
lemma start_sttp_resp_cons_comb_cons_r: "\<lbrakk> start_sttp_resp f; start_sttp_resp_cons f'\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   731
  \<Longrightarrow> start_sttp_resp_cons (f \<box> f')"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   732
apply (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   733
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   734
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   735
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   736
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   737
lemma start_sttp_resp_cons_comb [simp]: "start_sttp_resp_cons f 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   738
  \<Longrightarrow> start_sttp_resp (f \<box> f')"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   739
by (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   740
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   741
lemma start_sttp_resp_comb: "\<lbrakk> start_sttp_resp f; start_sttp_resp f' \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   742
  \<Longrightarrow> start_sttp_resp (f \<box> f')"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   743
apply (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   744
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   745
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   746
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   747
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   748
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   749
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   750
lemma start_sttp_resp_cons_nochangeST [simp]: "start_sttp_resp_cons nochangeST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   751
by (simp add: start_sttp_resp_cons_def nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   752
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   753
lemma start_sttp_resp_cons_pushST [simp]: "start_sttp_resp_cons (pushST Ts)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   754
by (simp add: start_sttp_resp_cons_def pushST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   755
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   756
lemma start_sttp_resp_cons_dupST [simp]: "start_sttp_resp_cons dupST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   757
by (simp add: start_sttp_resp_cons_def dupST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   758
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   759
lemma start_sttp_resp_cons_dup_x1ST [simp]: "start_sttp_resp_cons dup_x1ST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   760
by (simp add: start_sttp_resp_cons_def dup_x1ST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   761
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   762
lemma start_sttp_resp_cons_popST [simp]: "start_sttp_resp_cons (popST n)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   763
by (simp add: start_sttp_resp_cons_def popST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   764
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   765
lemma start_sttp_resp_cons_replST [simp]: "start_sttp_resp_cons (replST n tp)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   766
by (simp add: start_sttp_resp_cons_def replST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   767
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   768
lemma start_sttp_resp_cons_storeST [simp]: "start_sttp_resp_cons (storeST i tp)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   769
by (simp add: start_sttp_resp_cons_def storeST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   770
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   771
lemma start_sttp_resp_cons_compTpExpr [simp]: "start_sttp_resp_cons (compTpExpr jmb G ex)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   772
apply (induct ex)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   773
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   774
apply (simp add: start_sttp_resp_cons_def comb_def pushST_def split_beta) (* LAcc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   775
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   776
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   777
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   778
lemma start_sttp_resp_cons_compTpInit [simp]: "start_sttp_resp_cons (compTpInit jmb lv)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   779
by (simp add: compTpInit_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   780
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   781
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   782
lemma start_sttp_resp_nochangeST [simp]: "start_sttp_resp nochangeST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   783
by (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   784
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   785
lemma start_sttp_resp_pushST [simp]: "start_sttp_resp (pushST Ts)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   786
by (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   787
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   788
lemma start_sttp_resp_dupST [simp]: "start_sttp_resp dupST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   789
by (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   790
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   791
lemma start_sttp_resp_dup_x1ST [simp]: "start_sttp_resp dup_x1ST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   792
by (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   793
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   794
lemma start_sttp_resp_popST [simp]: "start_sttp_resp (popST n)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   795
by (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   796
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   797
lemma start_sttp_resp_replST [simp]: "start_sttp_resp (replST n tp)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   798
by (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   799
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   800
lemma start_sttp_resp_storeST [simp]: "start_sttp_resp (storeST i tp)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   801
by (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   802
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   803
lemma start_sttp_resp_compTpExpr [simp]: "start_sttp_resp (compTpExpr jmb G ex)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   804
by (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   805
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   806
lemma start_sttp_resp_compTpExprs [simp]: "start_sttp_resp (compTpExprs jmb G exs)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   807
by (induct exs, (simp add: start_sttp_resp_comb)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   808
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   809
lemma start_sttp_resp_compTpStmt [simp]: "start_sttp_resp (compTpStmt jmb G s)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   810
by (induct s, (simp add: start_sttp_resp_comb)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   811
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   812
lemma start_sttp_resp_compTpInitLvars [simp]: "start_sttp_resp (compTpInitLvars jmb lvars)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   813
by (induct lvars, simp+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   814
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   815
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   816
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   817
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   818
  (* ********************************************************************** *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   819
  (* length of compExpr/ compTpExprs *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   820
  (* ********************************************************************** *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   821
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   822
lemma length_comb [simp]:  "length (mt_of ((f1 \<box> f2) sttp)) = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   823
  length (mt_of (f1 sttp)) + length (mt_of (f2 (sttp_of (f1 sttp))))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   824
by (simp add: comb_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   825
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   826
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   827
lemma length_comb_nil [simp]: "length (mt_of (comb_nil sttp)) = 0"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   828
by (simp add: comb_nil_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   829
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   830
lemma length_nochangeST [simp]: "length (mt_of (nochangeST sttp)) = 1"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   831
by (simp add: nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   832
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   833
lemma length_pushST [simp]: "length (mt_of (pushST Ts sttp)) = 1"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   834
by (simp add: pushST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   835
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   836
lemma length_dupST [simp]: "length (mt_of (dupST sttp)) = 1"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   837
by (simp add: dupST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   838
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   839
lemma length_dup_x1ST [simp]: "length (mt_of (dup_x1ST sttp)) = 1"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   840
by (simp add: dup_x1ST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   841
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   842
lemma length_popST [simp]: "length (mt_of (popST n sttp)) = 1"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   843
by (simp add: popST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   844
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   845
lemma length_replST [simp]: "length (mt_of (replST n tp sttp)) = 1"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   846
by (simp add: replST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   847
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   848
lemma length_storeST [simp]: "length (mt_of (storeST i tp sttp)) = 1"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   849
by (simp add: storeST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   850
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   851
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   852
lemma length_compTpExpr_Exprs [rule_format]: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   853
  (\<forall> sttp. (length (mt_of (compTpExpr jmb G ex sttp)) = length (compExpr jmb ex)))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   854
  \<and> (\<forall> sttp. (length (mt_of (compTpExprs jmb G exs sttp)) = length (compExprs jmb exs)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   855
apply (rule  expr.induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   856
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   857
apply (case_tac binop)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   858
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   859
apply (simp add: pushST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   860
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   861
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   862
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   863
lemma length_compTpExpr: "length (mt_of (compTpExpr jmb G ex sttp)) = length (compExpr jmb ex)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   864
by (rule length_compTpExpr_Exprs [THEN conjunct1 [THEN spec]])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   865
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   866
lemma length_compTpExprs: "length (mt_of (compTpExprs jmb G exs sttp)) = length (compExprs jmb exs)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   867
by (rule length_compTpExpr_Exprs [THEN conjunct2 [THEN spec]])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   868
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   869
lemma length_compTpStmt [rule_format]: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   870
  (\<forall> sttp. (length (mt_of (compTpStmt jmb G s sttp)) = length (compStmt jmb s)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   871
apply (rule stmt.induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   872
apply (simp add: length_compTpExpr)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   873
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   874
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   875
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   876
lemma length_compTpInit: "length (mt_of (compTpInit jmb lv sttp)) = length (compInit jmb lv)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   877
by (simp add: compTpInit_def compInit_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   878
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   879
lemma length_compTpInitLvars [rule_format]: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   880
  "\<forall> sttp. length (mt_of (compTpInitLvars jmb lvars sttp)) = length (compInitLvars jmb lvars)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   881
by (induct lvars,  (simp add: compInitLvars_def length_compTpInit split_beta)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   882
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   883
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   884
  (* ********************************************************************** *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   885
  (* Correspondence bytecode - method types *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   886
  (* ********************************************************************** *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   887
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   888
syntax
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   889
  ST_of :: "state_type \<Rightarrow> opstack_type"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   890
  LT_of :: "state_type \<Rightarrow> locvars_type"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   891
translations
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   892
  "ST_of" => "fst"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   893
  "LT_of" => "snd"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   894
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   895
lemma states_lower:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   896
  "\<lbrakk> OK (Some (ST, LT)) \<in> states cG mxs mxr; length ST \<le> mxs\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   897
  \<Longrightarrow> OK (Some (ST, LT)) \<in> states cG (length ST) mxr"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   898
apply (simp add: states_def JVMType.sl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   899
apply (simp add: Product.esl_def stk_esl_def reg_sl_def upto_esl_def Listn.sl_def Err.sl_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   900
  JType.esl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   901
apply (simp add: Err.esl_def Err.le_def Listn.le_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   902
apply (simp add: Product.le_def Product.sup_def Err.sup_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   903
apply (simp add: Opt.esl_def Listn.sup_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   904
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   905
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   906
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   907
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   908
lemma check_type_lower:
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   909
  "\<lbrakk> check_type cG mxs mxr (OK (Some (ST, LT))); length ST \<le> mxs\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   910
  \<Longrightarrow>check_type cG (length ST) mxr (OK (Some (ST, LT)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   911
by (simp add: check_type_def states_lower)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   912
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   913
lemma max_same_iter [simp]: "max (x::'a::linorder) (max x y) = max x y"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   914
by (simp del: max_assoc add: max_assoc [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   915
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   916
  (* ******************************************************************* *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   917
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   918
constdefs
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   919
   bc_mt_corresp :: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   920
  [bytecode, state_type \<Rightarrow> method_type \<times> state_type, state_type, jvm_prog, ty, nat, p_count]
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   921
  \<Rightarrow> bool"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   922
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   923
  "bc_mt_corresp bc f sttp0 cG rT mxr idx ==
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   924
  let (mt, sttp) = f sttp0 in
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   925
  (length bc = length mt \<and> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   926
    ((check_type cG (length (ST_of sttp0)) mxr (OK (Some sttp0))) \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   927
    (\<forall>  mxs. 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   928
     mxs = max_ssize (mt@[Some sttp]) \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   929
     (\<forall> pc. pc < idx \<longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   930
      wt_instr_altern (bc ! pc) cG rT (mt@[Some sttp]) mxs mxr (length mt + 1) empty_et pc)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   931
     \<and> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   932
     check_type cG mxs mxr (OK ((mt@[Some sttp]) ! idx)))))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   933
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   934
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   935
lemma bc_mt_corresp_comb: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   936
  \<lbrakk> bc' = (bc1@bc2); l' = (length bc');
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   937
  bc_mt_corresp bc1 f1 sttp0 cG rT mxr (length bc1);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   938
  bc_mt_corresp bc2 f2 (sttp_of (f1 sttp0)) cG rT mxr (length bc2);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   939
  start_sttp_resp f2\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   940
\<Longrightarrow> bc_mt_corresp bc' (f1 \<box> f2) sttp0 cG rT mxr l'"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   941
apply (subgoal_tac "\<exists> mt1 sttp1. (f1 sttp0) = (mt1, sttp1)", (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   942
apply (subgoal_tac "\<exists> mt2 sttp2. (f2 sttp1) = (mt2, sttp2)", (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   943
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   944
  (* unfold start_sttp_resp and make case distinction *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   945
apply (simp only: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   946
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   947
  (* case f2 = comb_nil *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   948
apply (simp add: bc_mt_corresp_def comb_nil_def start_sttp_resp_cons_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   949
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   950
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   951
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   952
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   953
  (* case start_sttp_resp_cons f2 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   954
apply (simp add: bc_mt_corresp_def comb_def start_sttp_resp_cons_def del: all_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   955
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   956
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   957
apply (drule mp, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   958
apply (subgoal_tac "check_type cG (length (fst sttp1)) mxr (OK (Some sttp1))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   959
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   960
apply (drule mp, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   961
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   962
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   963
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   964
  (* show wt_instr  \<dots> *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   965
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   966
apply (drule_tac x=sttp1 in spec, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   967
apply (erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   968
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   969
apply (case_tac "pc < length mt1")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   970
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   971
  (* case pc < length mt1 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   972
apply (drule spec, drule mp, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   973
apply simp 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   974
apply (rule_tac mt="mt1 @ [Some sttp1]" in wt_instr_prefix)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   975
  apply assumption+ apply (rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   976
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   977
  apply (simp (no_asm_simp) add: max_ssize_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   978
  apply (simp add: max_of_list_def max_ac)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   979
  apply arith
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   980
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   981
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   982
  (* case pc \<ge> length mt1 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   983
apply (rule_tac bc=bc2 and mt=mt2 and bc_post="[]" and mt_post="[Some sttp2]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   984
  and mxr=mxr 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   985
  in wt_instr_offset)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   986
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   987
apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   988
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   989
apply (simp add: max_ssize_def max_of_list_append) apply (simp (no_asm_simp) add: max_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   990
apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   991
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   992
  (* show check_type \<dots> *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   993
apply (subgoal_tac "((mt2 @ [Some sttp2]) ! length bc2) = Some sttp2")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   994
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   995
apply (rule check_type_mono) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   996
apply (simp (no_asm_simp)  add: max_ssize_def max_of_list_append max_ac)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   997
apply arith
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   998
apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
   999
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1000
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1001
apply (case_tac sttp1)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1002
apply (simp add: check_type_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1003
apply (rule states_lower, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1004
apply (simp (no_asm_simp) add: max_ssize_def max_of_list_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1005
apply (simp (no_asm_simp) add: max_of_list_def ssize_sto_def max_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1006
apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1007
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1008
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1009
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1010
lemma bc_mt_corresp_zero [simp]: "\<lbrakk> length (mt_of (f sttp)) = length bc; start_sttp_resp f\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1011
  \<Longrightarrow> bc_mt_corresp bc f sttp cG rT mxr 0"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1012
apply (simp add: bc_mt_corresp_def start_sttp_resp_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1013
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1014
apply (simp add: max_ssize_def max_of_list_def ssize_sto_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1015
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1016
apply (simp add: start_sttp_resp_cons_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1017
apply (drule_tac x=sttp in spec, erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1018
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1019
apply (rule check_type_mono, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1020
apply (simp add: max_ssize_def max_of_list_def ssize_sto_def max_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1021
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1022
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1023
  (* ********************************************************************** *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1024
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1025
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1026
constdefs
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1027
  mt_sttp_flatten :: "method_type \<times> state_type \<Rightarrow> method_type"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1028
  "mt_sttp_flatten mt_sttp == (mt_of mt_sttp) @ [Some (sttp_of mt_sttp)]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1029
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1030
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1031
lemma mt_sttp_flatten_length [simp]: "n = (length (mt_of (f sttp)))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1032
 \<Longrightarrow> (mt_sttp_flatten (f sttp)) ! n = Some (sttp_of (f sttp))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1033
by (simp add: mt_sttp_flatten_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1034
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1035
lemma mt_sttp_flatten_comb: "(mt_sttp_flatten ((f1 \<box> f2) sttp)) = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1036
  (mt_of (f1 sttp)) @ (mt_sttp_flatten (f2 (sttp_of (f1 sttp))))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1037
by (simp add: mt_sttp_flatten_def comb_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1038
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1039
lemma mt_sttp_flatten_comb_length [simp]: "\<lbrakk> n1 = length (mt_of (f1 sttp)); n1 \<le> n \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1040
  \<Longrightarrow> (mt_sttp_flatten ((f1 \<box> f2) sttp) ! n) = (mt_sttp_flatten (f2 (sttp_of (f1 sttp))) ! (n - n1))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1041
by (simp add: mt_sttp_flatten_comb nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1042
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1043
lemma mt_sttp_flatten_comb_zero [simp]: "start_sttp_resp f 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1044
  \<Longrightarrow> (mt_sttp_flatten (f sttp)) ! 0 = Some sttp"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1045
apply (simp only: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1046
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1047
apply (simp add: comb_nil_def mt_sttp_flatten_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1048
apply (simp add: start_sttp_resp_cons_def mt_sttp_flatten_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1049
apply (drule_tac x=sttp in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1050
apply (erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1051
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1052
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1053
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1054
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1055
(* move into prelude -- compare with nat_int_length *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1056
lemma int_outside_right: "0 \<le> (m::int) \<Longrightarrow> m + (int n) = int ((nat m) + n)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1057
by simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1058
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1059
lemma int_outside_left: "0 \<le> (m::int) \<Longrightarrow> (int n) + m = int (n + (nat m))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1060
by simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1061
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1062
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1063
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1064
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1065
  (* ********************************************************************** *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1066
  (* bc_mt_corresp for individual instructions                              *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1067
  (* ---------------------------------------------------------------------- *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1068
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1069
lemma less_Suc [simp] : "n \<le> k \<Longrightarrow> (k < Suc n) = (k = n)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1070
  by arith
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1071
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1072
lemmas check_type_simps = check_type_def states_def JVMType.sl_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1073
   Product.esl_def stk_esl_def reg_sl_def upto_esl_def Listn.sl_def Err.sl_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1074
  JType.esl_def Err.esl_def Err.le_def Listn.le_def Product.le_def Product.sup_def Err.sup_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1075
  Opt.esl_def Listn.sup_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1076
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1077
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1078
lemma check_type_push: "\<lbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1079
  is_class cG cname; check_type cG (length ST) mxr (OK (Some (ST, LT))) \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1080
  \<Longrightarrow> check_type cG (Suc (length ST)) mxr (OK (Some (Class cname # ST, LT)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1081
apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1082
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1083
apply (rule_tac x="Suc (length ST)" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1084
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1085
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1086
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1087
lemma bc_mt_corresp_New: "\<lbrakk>is_class cG cname \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1088
  \<Longrightarrow> bc_mt_corresp [New cname] (pushST [Class cname]) (ST, LT) cG rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1089
apply (simp add: bc_mt_corresp_def pushST_def wt_instr_altern_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1090
    max_ssize_def max_of_list_def ssize_sto_def max_def 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1091
    eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1092
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1093
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1094
apply (rule check_type_mono, assumption, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1095
apply (simp add: check_type_push)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1096
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1097
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1098
lemma bc_mt_corresp_Pop: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1099
  bc_mt_corresp [Pop] (popST (Suc 0)) (T # ST, LT) cG rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1100
  apply (simp add: bc_mt_corresp_def popST_def wt_instr_altern_def eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1101
  apply (simp add: max_ssize_def ssize_sto_def max_of_list_def) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1102
  apply (simp add: max_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1103
  apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1104
  apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1105
  apply (rule_tac x="(length ST)" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1106
  apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1107
  done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1108
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1109
lemma bc_mt_corresp_Checkcast: "\<lbrakk> is_class cG cname; sttp = (ST, LT); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1110
  (\<exists>rT STo. ST = RefT rT # STo) \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1111
  \<Longrightarrow> bc_mt_corresp [Checkcast cname] (replST (Suc 0) (Class cname)) sttp cG rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1112
  apply (erule exE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1113
  apply (simp add: bc_mt_corresp_def replST_def wt_instr_altern_def eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1114
  apply (simp add: max_ssize_def max_of_list_def ssize_sto_def max_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1115
  apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1116
  apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1117
  apply (rule_tac x="Suc (length STo)" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1118
  apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1119
  done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1120
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1121
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1122
lemma bc_mt_corresp_LitPush: "\<lbrakk> typeof (\<lambda>v. None) val = Some T \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1123
  \<Longrightarrow> bc_mt_corresp [LitPush val] (pushST [T]) sttp cG rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1124
apply (subgoal_tac "\<exists> ST LT. sttp= (ST, LT)", (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1125
  apply (simp add: bc_mt_corresp_def pushST_def wt_instr_altern_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1126
                 max_ssize_def max_of_list_def ssize_sto_def max_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1127
                 eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1128
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1129
  apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1130
  apply (rule check_type_mono, assumption, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1131
  apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1132
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1133
apply (rule_tac x="Suc (length ST)" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1134
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1135
apply (drule sym)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1136
apply (case_tac val)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1137
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1138
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1139
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1140
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1141
lemma bc_mt_corresp_LitPush_CT: "\<lbrakk> typeof (\<lambda>v. None) val = Some T \<and> cG \<turnstile> T \<preceq> T';
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1142
  is_type cG T' \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1143
  \<Longrightarrow> bc_mt_corresp [LitPush val] (pushST [T']) sttp cG rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1144
apply (subgoal_tac "\<exists> ST LT. sttp= (ST, LT)", (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1145
  apply (simp add: bc_mt_corresp_def pushST_def wt_instr_altern_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1146
                 max_ssize_def max_of_list_def ssize_sto_def max_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1147
                 eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1148
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1149
  apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1150
  apply (rule check_type_mono, assumption, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1151
  apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1152
  apply (simp add: sup_state_Cons)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1153
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1154
apply (rule_tac x="Suc (length ST)" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1155
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1156
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1157
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1158
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1159
lemma bc_mt_corresp_Load: "\<lbrakk> i < length LT; LT ! i \<noteq> Err; mxr = length LT \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1160
  \<Longrightarrow> bc_mt_corresp [Load i] 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1161
         (\<lambda>(ST, LT). pushST [ok_val (LT ! i)] (ST, LT)) (ST, LT) cG rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1162
apply (simp add: bc_mt_corresp_def pushST_def wt_instr_altern_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1163
                 max_ssize_def max_of_list_def ssize_sto_def max_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1164
                 eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1165
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1166
  apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1167
  apply (rule check_type_mono, assumption, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1168
apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1169
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1170
apply (rule_tac x="Suc (length ST)" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1171
apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1172
  apply (simp only: err_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1173
  apply (frule listE_nth_in) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1174
apply (subgoal_tac "LT ! i \<in> {x. \<exists>y\<in>types cG. x = OK y}")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1175
apply (drule CollectD) apply (erule bexE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1176
apply (simp (no_asm_simp) )
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1177
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1178
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1179
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1180
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1181
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1182
lemma bc_mt_corresp_Store_init: "\<lbrakk> i < length LT \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1183
  \<Longrightarrow> bc_mt_corresp [Store i] (storeST i T) (T # ST, LT) cG rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1184
 apply (simp add: bc_mt_corresp_def storeST_def wt_instr_altern_def eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1185
  apply (simp add: max_ssize_def  max_of_list_def )
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1186
  apply (simp add: ssize_sto_def) apply (simp add: max_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1187
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1188
apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1189
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1190
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1191
apply (rule_tac x="(length ST)" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1192
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1193
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1194
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1195
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1196
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1197
lemma bc_mt_corresp_Store: "\<lbrakk> i < length LT; cG  \<turnstile>  LT[i := OK T] <=l LT \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1198
  \<Longrightarrow> bc_mt_corresp [Store i] (popST (Suc 0)) (T # ST, LT) cG rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1199
  apply (simp add: bc_mt_corresp_def popST_def wt_instr_altern_def eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1200
  apply (simp add: sup_state_conv)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1201
  apply (simp add: max_ssize_def max_of_list_def ssize_sto_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1202
  apply (simp add: max_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1203
 apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1204
apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1205
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1206
apply (rule_tac x="(length ST)" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1207
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1208
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1209
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1210
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1211
lemma bc_mt_corresp_Dup: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1212
  bc_mt_corresp [Dup] dupST (T # ST, LT) cG rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1213
 apply (simp add: bc_mt_corresp_def dupST_def wt_instr_altern_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1214
                 max_ssize_def max_of_list_def ssize_sto_def max_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1215
                 eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1216
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1217
  apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1218
  apply (rule check_type_mono, assumption, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1219
apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1220
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1221
apply (rule_tac x="Suc (Suc (length ST))" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1222
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1223
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1224
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1225
lemma bc_mt_corresp_Dup_x1: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1226
  bc_mt_corresp [Dup_x1] dup_x1ST (T1 # T2 # ST, LT) cG rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1227
  apply (simp add: bc_mt_corresp_def dup_x1ST_def wt_instr_altern_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1228
                 max_ssize_def max_of_list_def ssize_sto_def max_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1229
                 eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1230
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1231
  apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1232
  apply (rule check_type_mono, assumption, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1233
apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1234
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1235
apply (rule_tac x="Suc (Suc (Suc (length ST)))" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1236
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1237
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1238
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1239
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1240
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1241
lemma bc_mt_corresp_IAdd: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1242
  bc_mt_corresp [IAdd] (replST 2 (PrimT Integer)) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1243
         (PrimT Integer # PrimT Integer # ST, LT) cG rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1244
  apply (simp add: bc_mt_corresp_def replST_def wt_instr_altern_def eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1245
  apply (simp add: max_ssize_def max_of_list_def ssize_sto_def max_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1246
  apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1247
  apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1248
  apply (rule_tac x="Suc (length ST)" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1249
  apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1250
  done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1251
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1252
lemma bc_mt_corresp_Getfield: "\<lbrakk> wf_prog wf_mb G; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1253
  field (G, C) vname = Some (cname, T);  is_class G C \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1254
  \<Longrightarrow> bc_mt_corresp [Getfield vname cname] 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1255
        (replST (Suc 0) (snd (the (field (G, cname) vname))))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1256
        (Class C # ST, LT) (comp G) rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1257
  apply (frule wf_subcls1)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1258
  apply (frule field_in_fd, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1259
  apply (frule widen_field, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1260
  apply (simp add: bc_mt_corresp_def replST_def wt_instr_altern_def eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1261
  apply (simp add: comp_field [THEN sym] comp_subcls1 [THEN sym] comp_widen [THEN sym] comp_is_class [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1262
  apply (simp add: max_ssize_def max_of_list_def ssize_sto_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1263
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1264
apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1265
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1266
apply (rule_tac x="Suc (length ST)" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1267
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1268
apply (simp only: comp_is_type [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1269
apply (rule_tac C=cname in fields_is_type)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1270
apply (simp add: field_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1271
apply (drule JBasis.table_of_remap_SomeD)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1272
apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1273
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1274
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1275
lemma bc_mt_corresp_Putfield: "\<lbrakk> wf_prog wf_mb G; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1276
  field (G, C) vname = Some (cname, Ta); G \<turnstile> T \<preceq> Ta; is_class G C \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1277
  \<Longrightarrow> bc_mt_corresp [Putfield vname cname] (popST 2) (T # Class C # T # ST, LT)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1278
           (comp G) rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1279
  apply (frule wf_subcls1)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1280
  apply (frule field_in_fd, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1281
  apply (frule widen_field, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1282
  apply (simp add: bc_mt_corresp_def popST_def wt_instr_altern_def eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1283
  apply (simp add: comp_field [THEN sym] comp_subcls1 [THEN sym] comp_widen [THEN sym] comp_is_class [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1284
  apply (simp add: max_ssize_def max_of_list_def ssize_sto_def max_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1285
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1286
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1287
apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1288
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1289
apply (rule_tac x="Suc (length ST)" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1290
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1291
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1292
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1293
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1294
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1295
lemma Call_app: "\<lbrakk> wf_prog wf_mb G; is_class G cname;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1296
STs = rev pTsa @ Class cname # ST;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1297
max_spec G cname (mname, pTsa) = {((md, T), pTs')} \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1298
  \<Longrightarrow> app (Invoke cname mname pTs') (comp G) (length (T # ST)) rT 0 empty_et (Some (STs, LTs))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1299
  apply (subgoal_tac "(\<exists>mD' rT' comp_b. 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1300
    method (comp G, cname) (mname, pTs') = Some (mD', rT', comp_b))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1301
  apply (simp add: comp_is_class)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1302
  apply (rule_tac x=pTsa in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1303
  apply (rule_tac x="Class cname" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1304
  apply (simp add: max_spec_preserves_length comp_is_class [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1305
  apply (frule max_spec2mheads, (erule exE)+, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1306
  apply (simp add: comp_widen list_all2_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1307
  apply (frule max_spec2mheads, (erule exE)+, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1308
  apply (rule exI)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1309
  apply (rule comp_method)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1310
  apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1311
  done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1312
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1313
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1314
lemma bc_mt_corresp_Invoke: "\<lbrakk> wf_prog wf_mb G; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1315
  max_spec G cname (mname, pTsa) = {((md, T), fpTs)};
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1316
  is_class G cname \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1317
 \<Longrightarrow> bc_mt_corresp [Invoke cname mname fpTs] (replST (Suc (length pTsa)) T)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1318
           (rev pTsa @ Class cname # ST, LT) (comp G) rT mxr (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1319
  apply (simp add: bc_mt_corresp_def wt_instr_altern_def eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1320
  apply (simp add: replST_def del: appInvoke)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1321
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1322
  apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1323
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1324
  -- "app"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1325
  apply (rule Call_app [THEN app_mono_mxs]) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1326
    apply (rule HOL.refl) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1327
    apply (simp add: max_ssize_def max_of_list_elem ssize_sto_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1328
13676
b1915d3e571d fixed latex error
kleing
parents: 13673
diff changeset
  1329
  -- {* @{text "<=s"} *}
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1330
  apply (frule max_spec2mheads, (erule exE)+, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1331
  apply (frule comp_method, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1332
  apply (simp add: max_spec_preserves_length [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1333
13676
b1915d3e571d fixed latex error
kleing
parents: 13673
diff changeset
  1334
  -- "@{text check_type}"
13673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1335
apply (simp add: max_ssize_def ssize_sto_def max_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1336
apply (simp add: max_of_list_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1337
apply (subgoal_tac "(max (length pTsa + length ST) (length ST)) = (length pTsa + length ST)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1338
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1339
apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1340
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1341
apply (rule_tac x="Suc (length ST)" in exI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1342
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1343
apply (simp only: comp_is_type [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1344
apply (frule method_wf_mdecl) apply assumption apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1345
apply (simp add: wf_mdecl_def wf_mhead_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1346
apply (simp add: max_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1347
  done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1348
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1349
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1350
lemma wt_instr_Ifcmpeq: "\<lbrakk>Suc pc < max_pc; 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1351
  0 \<le> (int pc + i);  nat (int pc + i) < max_pc;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1352
  (mt_sttp_flatten f ! pc = Some (ts#ts'#ST,LT)) \<and> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1353
  ((\<exists>p. ts = PrimT p \<and> ts' = PrimT p) \<or> (\<exists>r r'. ts = RefT r \<and> ts' = RefT r'));
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1354
  mt_sttp_flatten f ! Suc pc = Some (ST,LT);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1355
  mt_sttp_flatten f ! nat (int pc + i) = Some (ST,LT);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1356
  check_type (TranslComp.comp G) mxs mxr (OK (Some (ts # ts' # ST, LT))) \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1357
    \<Longrightarrow>  wt_instr_altern (Ifcmpeq i) (comp G) rT  (mt_sttp_flatten f) mxs mxr max_pc empty_et pc"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1358
by (simp  add: wt_instr_altern_def eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1359
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1360
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1361
lemma wt_instr_Goto: "\<lbrakk> 0 \<le> (int pc + i); nat (int pc + i) < max_pc;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1362
  mt_sttp_flatten f ! nat (int pc + i) = (mt_sttp_flatten f ! pc);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1363
  check_type (TranslComp.comp G) mxs mxr (OK (mt_sttp_flatten f ! pc)) \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1364
  \<Longrightarrow> wt_instr_altern (Goto i) (comp G) rT  (mt_sttp_flatten f) mxs mxr max_pc empty_et pc"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1365
apply (case_tac "(mt_sttp_flatten f ! pc)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1366
apply (simp  add: wt_instr_altern_def eff_def norm_eff_def app_def xcpt_app_def)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1367
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1368
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1369
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1370
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1371
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1372
  (* ********************************************************************** *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1373
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1374
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1375
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1376
lemma bc_mt_corresp_comb_inside: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1377
  \<lbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1378
  bc_mt_corresp bc' f' sttp0 cG rT mxr l1;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1379
  bc' = (bc1@bc2@bc3); f'= (f1 \<box> f2 \<box> f3); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1380
  l1 = (length bc1); l12 = (length (bc1@bc2));
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1381
  bc_mt_corresp bc2 f2 (sttp_of (f1 sttp0)) cG rT mxr (length bc2);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1382
  length bc1 = length (mt_of (f1 sttp0));
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1383
  start_sttp_resp f2; start_sttp_resp f3\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1384
\<Longrightarrow> bc_mt_corresp bc' f' sttp0 cG rT mxr l12"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1385
apply (subgoal_tac "\<exists> mt1 sttp1. (f1 sttp0) = (mt1, sttp1)", (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1386
apply (subgoal_tac "\<exists> mt2 sttp2. (f2 sttp1) = (mt2, sttp2)", (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1387
apply (subgoal_tac "\<exists> mt3 sttp3. (f3 sttp2) = (mt3, sttp3)", (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1388
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1389
  (* unfold start_sttp_resp and make case distinction *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1390
apply (simp only: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1391
apply (erule_tac Q="start_sttp_resp_cons f2" in disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1392
  (* case f2 = comb_nil *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1393
apply (simp add: bc_mt_corresp_def comb_nil_def start_sttp_resp_cons_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1394
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1395
  (* case start_sttp_resp_cons f2 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1396
apply (simp add: bc_mt_corresp_def comb_def start_sttp_resp_cons_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1397
apply (drule_tac x=sttp1 in spec, simp, erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1398
apply (intro strip, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1399
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1400
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1401
  (* get rid of all check_type info *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1402
apply (subgoal_tac "check_type cG (length (fst sttp1)) mxr (OK (Some sttp1))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1403
apply (subgoal_tac "check_type cG (max_ssize (mt2 @ [Some sttp2])) mxr (OK (Some sttp2))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1404
apply (subgoal_tac "check_type cG (max_ssize (mt1 @ mt2 @ mt3 @ [Some sttp3])) mxr
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1405
           (OK ((mt2 @ mt3 @ [Some sttp3]) ! length mt2))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1406
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1407
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1408
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1409
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1410
apply (intro strip, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1411
apply (case_tac "pc < length mt1")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1412
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1413
  (* case pc < length mt1 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1414
apply (drule spec, drule mp, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1415
apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1416
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1417
  (* case pc \<ge> length mt1 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1418
  (* case distinction on start_sttp_resp f3 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1419
apply (erule_tac P="f3 = comb_nil" in disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1420
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1421
  (* case f3 = comb_nil *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1422
apply (subgoal_tac "mt3 = [] \<and> sttp2 = sttp3")  apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1423
apply (subgoal_tac "bc3=[]")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1424
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1425
apply (rule_tac bc_pre=bc1 and bc=bc2 and bc_post=bc3
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1426
  and mt_pre=mt1 and mt=mt2 and mt_post="mt3@ [Some sttp3]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1427
  and mxs="(max_ssize (mt2 @ [(Some sttp2)]))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1428
  and max_pc="(Suc (length mt2))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1429
  in wt_instr_offset)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1430
  apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1431
  apply (rule HOL.refl)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1432
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1433
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1434
  apply (simp (no_asm_simp) add: max_ssize_def del: max_of_list_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1435
    apply (rule max_of_list_sublist)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1436
    apply (simp (no_asm_simp) only: set_append set.simps map.simps) apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1437
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1438
  apply simp			(* subgoal bc3 = [] *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1439
  apply (simp add: comb_nil_def) (* subgoal mt3 = [] \<and> sttp2 = sttp3 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1440
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1441
  (* case start_sttp_resp_cons f3 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1442
apply (subgoal_tac "\<exists>mt3_rest. (mt3 = Some sttp2 # mt3_rest)", erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1443
apply (rule_tac bc_pre=bc1 and bc=bc2 and bc_post=bc3
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1444
  and mt_pre=mt1 and mt=mt2 and mt_post="mt3@ [Some sttp3]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1445
  and mxs="(max_ssize (mt2 @ [Some sttp2]))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1446
  and max_pc="(Suc (length mt2))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1447
  in wt_instr_offset)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1448
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1449
apply (rule_tac bc=bc2 and mt="(mt2 @ [Some sttp2])"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1450
  and mxs="(max_ssize (mt2 @ [Some sttp2]))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1451
  and max_pc="(Suc (length mt2))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1452
  in wt_instr_prefix)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1453
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1454
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1455
     (* preconditions of  wt_instr_prefix *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1456
  apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1457
  apply (rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1458
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1459
  apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1460
     (* (some) preconditions of  wt_instr_offset *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1461
  apply (simp (no_asm_simp) add: max_ssize_def del: max_of_list_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1462
  apply (rule max_of_list_sublist)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1463
    apply (simp (no_asm_simp) only: set_append set.simps map.simps) apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1464
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1465
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1466
apply (drule_tac x=sttp2 in spec, simp) (* subgoal \<exists>mt3_rest. \<dots> *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1467
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1468
  (* subgoals check_type*)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1469
  (* \<dots> ! length mt2 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1470
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1471
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1472
apply (erule_tac P="f3 = comb_nil" in disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1473
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1474
  (* -- case f3 = comb_nil *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1475
apply (subgoal_tac "mt3 = [] \<and> sttp2 = sttp3")  apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1476
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1477
apply (rule check_type_mono, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1478
apply (simp only: max_ssize_def) apply (rule max_of_list_sublist) apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1479
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1480
  apply simp			(* subgoal bc3 = [] *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1481
  apply (simp add: comb_nil_def) (* subgoal mt3 = [] \<and> sttp2 = sttp3 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1482
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1483
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1484
  (* -- case start_sttp_resp_cons f3 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1485
apply (subgoal_tac "\<exists>mt3_rest. (mt3 = Some sttp2 # mt3_rest)", erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1486
apply (simp (no_asm_simp) add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1487
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1488
apply (rule check_type_mono, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1489
apply (simp only: max_ssize_def) apply (rule max_of_list_sublist) apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1490
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1491
apply (drule_tac x=sttp2 in spec, simp) (* subgoal \<exists>mt3_rest. \<dots> *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1492
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1493
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1494
  (* subgoal check_type \<dots> Some sttp2 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1495
apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1496
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1497
  (* subgoal check_type \<dots> Some sttp1 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1498
apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1499
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1500
apply (case_tac "sttp1", simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1501
apply (rule check_type_lower) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1502
apply (simp (no_asm_simp) add: max_ssize_def ssize_sto_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1503
apply (simp (no_asm_simp) add: max_of_list_def max_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1504
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1505
  (* subgoals \<exists> ... *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1506
apply (rule surj_pair)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1507
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1508
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1509
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1510
  (* ******************** *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1511
constdefs 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1512
  contracting :: "(state_type \<Rightarrow> method_type \<times> state_type) \<Rightarrow> bool"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1513
  "contracting f == (\<forall> ST LT. 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1514
                    let (ST', LT') = sttp_of (f (ST, LT)) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1515
                    in (length ST' \<le> length ST \<and> set ST' \<subseteq> set ST  \<and>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1516
                        length LT' = length LT \<and> set LT' \<subseteq> set LT))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1517
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1518
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1519
  (* ### possibly move into HOL *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1520
lemma set_drop_Suc [rule_format]: "\<forall> xs. set (drop (Suc n) xs) \<subseteq> set (drop n xs)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1521
apply (induct n)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1522
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1523
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1524
apply (rule list.induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1525
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1526
apply simp apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1527
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1528
apply (rule_tac 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1529
  P="\<lambda> xs. set (drop (Suc (Suc n)) xs) \<subseteq> set (drop (Suc n) xs)" in list.induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1530
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1531
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1532
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1533
lemma set_drop_le [rule_format,simp]: "\<forall> n xs. n \<le> m \<longrightarrow> set (drop m xs) \<subseteq> set (drop n xs)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1534
apply (induct m)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1535
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1536
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1537
apply (subgoal_tac "na \<le> n \<or> na = Suc n")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1538
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1539
apply (frule_tac x=na in spec, drule_tac x=xs in spec, drule mp, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1540
apply (rule set_drop_Suc [THEN subset_trans], assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1541
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1542
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1543
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1544
lemma set_drop [simp] : "set (drop m xs) \<subseteq> set xs"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1545
apply (rule_tac B="set (drop 0 xs)" in subset_trans)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1546
apply (rule set_drop_le)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1547
apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1548
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1549
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1550
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1551
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1552
lemma contracting_popST [simp]: "contracting (popST n)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1553
by (simp add: contracting_def popST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1554
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1555
lemma contracting_nochangeST [simp]: "contracting nochangeST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1556
by (simp add: contracting_def nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1557
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1558
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1559
lemma check_type_contracting: "\<lbrakk> check_type cG mxs mxr (OK (Some sttp)); contracting f\<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1560
  \<Longrightarrow> check_type cG mxs mxr (OK (Some (sttp_of (f sttp))))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1561
apply (subgoal_tac "\<exists> ST LT. sttp = (ST, LT)", (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1562
apply (simp add: check_type_simps contracting_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1563
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1564
apply (drule_tac x=ST in spec, drule_tac x=LT in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1565
apply (case_tac "(sttp_of (f (ST, LT)))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1566
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1567
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1568
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1569
apply (drule listE_set)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1570
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1571
apply (rule_tac x="length a" in exI) apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1572
apply (rule listI) apply simp apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1573
apply (rule listI) apply simp apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1574
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1575
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1576
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1577
  (* ******************** *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1578
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1579
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1580
lemma bc_mt_corresp_comb_wt_instr: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1581
  \<lbrakk> bc_mt_corresp bc' f' sttp0 cG rT mxr l1;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1582
  bc' = (bc1@[inst]@bc3); f'= (f1 \<box> f2 \<box> f3); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1583
  l1 = (length bc1); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1584
  length bc1 = length (mt_of (f1 sttp0));
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1585
  length (mt_of (f2 (sttp_of (f1 sttp0)))) = 1;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1586
  start_sttp_resp_cons f1; start_sttp_resp_cons f2; start_sttp_resp f3;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1587
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1588
  check_type cG (max_ssize (mt_sttp_flatten (f' sttp0))) mxr
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1589
             (OK ((mt_sttp_flatten (f' sttp0)) ! (length bc1)))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1590
  \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1591
  wt_instr_altern inst cG rT 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1592
      (mt_sttp_flatten (f' sttp0)) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1593
      (max_ssize (mt_sttp_flatten (f' sttp0)))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1594
      mxr
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1595
      (Suc (length bc'))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1596
      empty_et
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1597
      (length bc1);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1598
  contracting f2
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1599
 \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1600
\<Longrightarrow> bc_mt_corresp bc' f' sttp0 cG rT mxr (length (bc1@[inst]))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1601
apply (subgoal_tac "\<exists> mt1 sttp1. (f1 sttp0) = (mt1, sttp1)", (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1602
apply (subgoal_tac "\<exists> mt2 sttp2. (f2 sttp1) = (mt2, sttp2)", (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1603
apply (subgoal_tac "\<exists> mt3 sttp3. (f3 sttp2) = (mt3, sttp3)", (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1604
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1605
apply (simp add: bc_mt_corresp_def comb_def start_sttp_resp_cons_def
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1606
  mt_sttp_flatten_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1607
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1608
apply (intro strip, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1609
apply (drule mp, assumption)+ apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1610
apply (drule mp, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1611
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1612
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1613
  (* wt_instr \<dots> *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1614
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1615
apply (case_tac "pc < length mt1")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1616
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1617
  (* case pc < length mt1 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1618
apply (drule spec, drule mp, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1619
apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1620
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1621
  (* case pc \<ge> length mt1 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1622
apply (subgoal_tac "pc = length mt1") prefer 2 apply arith
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1623
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1624
apply (simp add: nth_append mt_sttp_flatten_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1625
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1626
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1627
  (* check_type \<dots> *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1628
apply (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1629
apply (drule_tac x="sttp0" in spec, simp, erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1630
apply (drule_tac x="sttp1" in spec, simp, erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1631
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1632
apply (subgoal_tac "check_type cG (max_ssize (mt1 @ mt2 @ mt3 @ [Some sttp3])) mxr 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1633
                    (OK (Some (sttp_of (f2 sttp1))))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1634
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1635
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1636
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1637
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1638
    (* case f3 = comb_nil *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1639
apply (subgoal_tac "((mt1 @ mt2 @ mt3 @ [Some sttp3]) ! Suc (length mt1)) = (Some (snd (f2 sttp1)))")apply (subgoal_tac "mt3 = [] \<and> sttp2 = sttp3")  apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1640
apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1641
apply (simp add: comb_nil_def) (* subgoal mt3 = [] \<and> sttp2 = sttp3 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1642
apply (simp add: nth_append comb_nil_def) (* subgoal \<dots> ! Suc (length mt1) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1643
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1644
    (* case start_sttp_resp_cons f3 *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1645
apply (simp add: start_sttp_resp_cons_def)  
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1646
apply (drule_tac x="sttp2" in spec, simp, erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1647
apply (simp  add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1648
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1649
  (* subgoal check_type *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1650
apply (rule check_type_contracting)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1651
apply (subgoal_tac "((mt1 @ mt2 @ mt3 @ [Some sttp3]) ! length mt1) = (Some sttp1)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1652
apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1653
apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1654
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1655
apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1656
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1657
(* subgoals *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1658
apply (rule surj_pair)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1659
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1660
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1661
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1662
lemma compTpExpr_LT_ST_rewr [simp]: "\<lbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1663
  wf_java_prog G;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1664
  wf_java_mdecl G C ((mn, pTs), rT, (pns, lvars, blk, res));
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1665
  local_env G C (mn, pTs) pns lvars \<turnstile> ex :: T;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1666
  is_inited_LT C pTs lvars LT\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1667
\<Longrightarrow> sttp_of (compTpExpr (pns, lvars, blk, res) G ex (ST, LT)) = (T # ST, LT)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1668
apply (rule compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1669
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1670
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1671
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1672
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1673
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1674
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1675
lemma wt_method_compTpExpr_Exprs_corresp: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1676
  \<lbrakk> jmb = (pns,lvars,blk,res); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1677
  wf_prog wf_java_mdecl G;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1678
  wf_java_mdecl G C ((mn, pTs), rT, jmb);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1679
  E = (local_env G C (mn, pTs) pns lvars)\<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1680
\<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1681
 (\<forall> ST LT T bc' f'.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1682
  E \<turnstile> ex :: T \<longrightarrow>  
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1683
  (is_inited_LT C pTs lvars LT) \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1684
  bc' = (compExpr jmb ex) \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1685
  f' = (compTpExpr jmb G ex)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1686
  \<longrightarrow> bc_mt_corresp bc' f' (ST, LT) (comp G) rT (length LT) (length bc'))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1687
 \<and>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1688
 (\<forall> ST LT Ts.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1689
  E \<turnstile> exs [::] Ts \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1690
  (is_inited_LT C pTs lvars LT) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1691
  \<longrightarrow> bc_mt_corresp (compExprs jmb exs) (compTpExprs jmb G exs) (ST, LT) (comp G) rT (length LT) (length (compExprs jmb exs)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1692
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1693
apply (rule  expr.induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1694
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1695
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1696
(* expresssions *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1697
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1698
(* NewC *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1699
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1700
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1701
apply (drule NewC_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1702
apply (simp (no_asm_use))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1703
apply (rule bc_mt_corresp_New)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1704
apply (simp add: comp_is_class)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1705
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1706
(* Cast *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1707
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1708
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1709
apply (drule Cast_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1710
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1711
apply (simp (no_asm_use))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1712
apply (rule bc_mt_corresp_comb) apply (rule HOL.refl, simp (no_asm_simp), blast)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1713
apply (simp (no_asm_simp), rule bc_mt_corresp_Checkcast)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1714
apply (simp add: comp_is_class)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1715
apply (simp only: compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1716
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1717
apply (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1718
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1719
(* Lit *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1720
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1721
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1722
apply (drule Lit_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1723
(* apply (simp (no_asm_use)) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1724
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1725
apply (rule bc_mt_corresp_LitPush)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1726
   apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1727
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1728
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1729
(* BinOp *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1730
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1731
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1732
apply (simp (no_asm_simp) only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1733
apply (drule BinOp_invers, erule exE, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1734
apply (case_tac binop)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1735
apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1736
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1737
  (* case Eq *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1738
apply (subgoal_tac "bc_mt_corresp bc' f' (ST, LT) (comp G) rT (length LT) 0")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1739
prefer 2
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1740
  apply (rule bc_mt_corresp_zero) apply (simp add: length_compTpExpr) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1741
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1742
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1743
apply (drule_tac "bc1.0"="[]" and "bc2.0" = "compExpr jmb expr1" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1744
  and "f1.0"=comb_nil and "f2.0" = "compTpExpr jmb G expr1" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1745
  in bc_mt_corresp_comb_inside)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1746
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1747
  apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1748
  apply (simp (no_asm_simp) add: length_compTpExpr)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1749
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1750
apply (drule_tac "bc2.0" = "compExpr jmb expr2" and "f2.0" = "compTpExpr jmb G expr2" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1751
  in bc_mt_corresp_comb_inside)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1752
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1753
  apply (simp only: compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1754
  apply (simp (no_asm_simp) add: length_compTpExpr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1755
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1756
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1757
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1758
apply (drule_tac "bc1.0" = "compExpr jmb expr1 @ compExpr jmb expr2" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1759
    and inst = "Ifcmpeq 3" and "bc3.0" = "[LitPush (Bool False),Goto 2, LitPush (Bool True)]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1760
  and "f1.0"="compTpExpr jmb G expr1 \<box> compTpExpr jmb G expr2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1761
  and "f2.0"="popST 2" and "f3.0"="pushST [PrimT Boolean] \<box> popST 1 \<box> pushST [PrimT Boolean]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1762
  in bc_mt_corresp_comb_wt_instr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1763
  apply (simp (no_asm_simp) add: length_compTpExpr)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1764
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1765
    (* wt_instr *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1766
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1767
  apply (simp (no_asm_simp) add: wt_instr_altern_def length_compTpExpr eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1768
  apply (simp (no_asm_simp) add: norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1769
  apply (simp (no_asm_simp) only: int_outside_left nat_int)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1770
  apply (simp (no_asm_simp) add: length_compTpExpr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1771
  apply (simp only: compTpExpr_LT_ST)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1772
  apply (simp add: eff_def norm_eff_def popST_def pushST_def mt_sttp_flatten_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1773
  apply (case_tac Ta) apply (simp (no_asm_simp)) apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1774
  apply (rule contracting_popST)		(* contracting (popST 2)  *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1775
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1776
apply (drule_tac "bc1.0" = "compExpr jmb expr1 @ compExpr jmb expr2 @ [Ifcmpeq 3]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1777
  and "bc2.0" = "[LitPush (Bool False)]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1778
  and "bc3.0" = "[Goto 2, LitPush (Bool True)]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1779
  and "f1.0" = "compTpExpr jmb G expr1 \<box> compTpExpr jmb G expr2 \<box> popST 2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1780
  and "f2.0" = "pushST [PrimT Boolean]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1781
  and "f3.0" = "popST (Suc 0) \<box> pushST [PrimT Boolean]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1782
  in bc_mt_corresp_comb_inside)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1783
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1784
  apply (simp add: compTpExpr_LT_ST_rewr popST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1785
  apply (rule_tac T="(PrimT Boolean)" in bc_mt_corresp_LitPush) apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1786
  apply (simp (no_asm_simp) add: length_compTpExpr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1787
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1788
  apply (simp (no_asm_simp) add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1789
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1790
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1791
apply (drule_tac "bc1.0" = "compExpr jmb expr1 @ compExpr jmb expr2 @ [Ifcmpeq 3, LitPush (Bool False)]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1792
    and inst = "Goto 2" and "bc3.0" = "[LitPush (Bool True)]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1793
  and "f1.0"="compTpExpr jmb G expr1 \<box> compTpExpr jmb G expr2 \<box> popST 2 \<box> pushST [PrimT Boolean]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1794
  and "f2.0"="popST 1" and "f3.0"="pushST [PrimT Boolean]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1795
  in bc_mt_corresp_comb_wt_instr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1796
  apply (simp (no_asm_simp) add: length_compTpExpr)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1797
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1798
    (* wt_instr *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1799
  apply (simp (no_asm_simp) add: wt_instr_altern_def length_compTpExpr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1800
  apply (simp (no_asm_simp) add: eff_def norm_eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1801
  apply (simp (no_asm_simp) only: int_outside_right nat_int)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1802
  apply (simp (no_asm_simp) add: length_compTpExpr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1803
  apply (simp only: compTpExpr_LT_ST)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1804
  apply (simp add: eff_def norm_eff_def popST_def pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1805
  apply (rule contracting_popST)		(* contracting (popST 1) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1806
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1807
apply (drule_tac 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1808
  "bc1.0" = "compExpr jmb expr1 @ compExpr jmb expr2 @ [Ifcmpeq 3, LitPush (Bool False), Goto 2]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1809
  and "bc2.0" = "[LitPush (Bool True)]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1810
  and "bc3.0" = "[]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1811
  and "f1.0" = "compTpExpr jmb G expr1 \<box> compTpExpr jmb G expr2 \<box> popST 2 \<box> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1812
                pushST [PrimT Boolean] \<box> popST (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1813
  and "f2.0" = "pushST [PrimT Boolean]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1814
  and "f3.0" = "comb_nil" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1815
  in bc_mt_corresp_comb_inside)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1816
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1817
  apply (simp add: compTpExpr_LT_ST_rewr popST_def) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1818
  apply (rule_tac T="(PrimT Boolean)" in bc_mt_corresp_LitPush) apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1819
  apply (simp (no_asm_simp) add: length_compTpExpr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1820
  apply (simp (no_asm_simp) add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1821
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1822
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1823
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1824
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1825
  (* case Add *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1826
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1827
apply (rule bc_mt_corresp_comb) apply (rule HOL.refl) apply simp apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1828
apply (rule bc_mt_corresp_comb, rule HOL.refl) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1829
   apply (simp only: compTpExpr_LT_ST) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1830
apply (simp only: compTpExpr_LT_ST) apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1831
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1832
apply (simp only: compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1833
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1834
apply (rule bc_mt_corresp_IAdd)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1835
apply (simp (no_asm_simp) add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1836
apply (simp (no_asm_simp) add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1837
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1838
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1839
  (* LAcc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1840
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1841
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1842
apply (drule LAcc_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1843
apply (frule wf_java_mdecl_length_pTs_pns)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1844
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1845
apply (simp add: is_inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1846
apply (rule bc_mt_corresp_Load)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1847
  apply (rule index_in_bounds) apply simp apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1848
  apply (rule inited_LT_at_index_no_err)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1849
  apply (rule index_in_bounds) apply simp apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1850
apply (rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1851
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1852
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1853
  (* LAss *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1854
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1855
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1856
apply (drule LAss_invers, erule exE, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1857
apply (drule LAcc_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1858
apply (frule wf_java_mdecl_disjoint_varnames, simp add: disjoint_varnames_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1859
apply (frule wf_java_mdecl_length_pTs_pns)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1860
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1861
apply (simp (no_asm_use))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1862
apply (rule bc_mt_corresp_comb) apply (rule HOL.refl, simp (no_asm_simp), blast)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1863
apply (rule_tac "bc1.0"="[Dup]" and "bc2.0"="[Store (index (pns, lvars, blk, res) vname)]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1864
       and "f1.0"="dupST" and "f2.0"="popST (Suc 0)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1865
       in bc_mt_corresp_comb) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1866
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1867
  apply (rule bc_mt_corresp_Dup)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1868
  apply (simp only: compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1869
  apply (simp add: dupST_def is_inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1870
  apply (rule bc_mt_corresp_Store)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1871
  apply (rule index_in_bounds)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1872
    apply simp apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1873
  apply (rule sup_loc_update_index, assumption+) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1874
    apply simp apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1875
apply (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1876
apply (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1877
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1878
  (* FAcc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1879
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1880
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1881
apply (drule FAcc_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1882
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1883
apply (simp (no_asm_use))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1884
apply (rule bc_mt_corresp_comb) apply (rule HOL.refl, simp (no_asm_simp), blast) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1885
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1886
  apply (rule bc_mt_corresp_Getfield) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1887
     apply (rule wt_class_expr_is_class, assumption+) apply (rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1888
apply (simp (no_asm_simp) add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1889
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1890
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1891
  (* FAss *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1892
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1893
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1894
apply (drule FAss_invers, erule exE, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1895
apply (drule FAcc_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1896
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1897
apply (simp (no_asm_use))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1898
apply (rule bc_mt_corresp_comb) apply (rule HOL.refl) apply simp apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1899
  apply (simp only: compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1900
apply (rule bc_mt_corresp_comb, (rule HOL.refl)+) apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1901
  apply (simp only: compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1902
apply (rule_tac "bc1.0"="[Dup_x1]" and "bc2.0"="[Putfield vname cname]" in bc_mt_corresp_comb) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1903
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1904
apply (rule bc_mt_corresp_Dup_x1)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1905
  apply (simp (no_asm_simp) add: dup_x1ST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1906
apply (rule bc_mt_corresp_Putfield) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1907
     apply (rule wt_class_expr_is_class, assumption+) apply (rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1908
apply (simp (no_asm_simp) add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1909
apply (simp (no_asm_simp) add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1910
apply (simp (no_asm_simp) add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1911
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1912
(* Call *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1913
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1914
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1915
apply (drule Call_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1916
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1917
apply (simp (no_asm_use))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1918
apply (rule bc_mt_corresp_comb) apply (rule HOL.refl) apply simp apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1919
  apply (simp only: compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1920
apply (rule bc_mt_corresp_comb, (rule HOL.refl)+) apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1921
  apply (simp only: compTpExprs_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1922
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1923
apply (rule bc_mt_corresp_Invoke) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1924
  apply (rule wt_class_expr_is_class, assumption+) apply (rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1925
apply (simp (no_asm_simp) add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1926
apply (rule start_sttp_resp_comb) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1927
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1928
  apply (simp (no_asm_simp) add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1929
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1930
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1931
(* expression lists *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1932
(* nil *) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1933
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1934
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1935
apply (drule Nil_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1936
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1937
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1938
(* cons *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1939
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1940
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1941
apply (drule Cons_invers, (erule exE)+, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1942
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1943
apply (simp (no_asm_use))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1944
apply (rule bc_mt_corresp_comb) apply (rule HOL.refl) apply simp apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1945
  apply (simp only: compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1946
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1947
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1948
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1949
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1950
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1951
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1952
lemmas wt_method_compTpExpr_corresp [rule_format (no_asm)] = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1953
  wt_method_compTpExpr_Exprs_corresp [THEN conjunct1]
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1954
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1955
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1956
  (* ********************************************************************** *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1957
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1958
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1959
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1960
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1961
lemma wt_method_compTpStmt_corresp [rule_format (no_asm)]: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1962
  \<lbrakk> jmb = (pns,lvars,blk,res); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1963
  wf_prog wf_java_mdecl G;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1964
  wf_java_mdecl G C ((mn, pTs), rT, jmb);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1965
  E = (local_env G C (mn, pTs) pns lvars)\<rbrakk> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1966
\<Longrightarrow> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1967
 (\<forall> ST LT T bc' f'.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1968
  E \<turnstile> s\<surd> \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1969
  (is_inited_LT C pTs lvars LT) \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1970
  bc' = (compStmt jmb s) \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1971
  f' = (compTpStmt jmb G s)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1972
  \<longrightarrow> bc_mt_corresp bc' f' (ST, LT) (comp G) rT (length LT) (length bc'))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1973
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1974
apply (rule stmt.induct)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1975
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1976
(* Skip *) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1977
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1978
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1979
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1980
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1981
(* Expr *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1982
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1983
apply (drule Expr_invers, erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1984
apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1985
apply (rule bc_mt_corresp_comb) apply (rule HOL.refl, simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1986
apply (rule wt_method_compTpExpr_corresp) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1987
apply (simp add: compTpExpr_LT_ST [of _ pns lvars blk res])+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1988
apply (rule bc_mt_corresp_Pop)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1989
apply (simp add: start_sttp_resp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1990
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1991
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1992
(* Comp *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1993
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1994
apply (drule Comp_invers)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1995
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1996
apply (simp (no_asm_use))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1997
apply (rule bc_mt_corresp_comb) apply (rule HOL.refl) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1998
   apply (simp (no_asm_simp)) apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  1999
apply (simp only: compTpStmt_LT_ST) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2000
apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2001
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2002
(* Cond *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2003
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2004
apply (simp (no_asm_simp) only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2005
apply (drule Cond_invers, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2006
apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2007
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2008
apply (subgoal_tac "bc_mt_corresp bc' f' (ST, LT) (comp G) rT (length LT) 0")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2009
prefer 2 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2010
apply (rule bc_mt_corresp_zero) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2011
  apply (simp (no_asm_simp) add: length_compTpStmt length_compTpExpr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2012
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2013
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2014
apply (drule_tac "bc1.0"="[]" and "bc2.0" = "[LitPush (Bool False)]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2015
  and "bc3.0"="compExpr jmb expr @ Ifcmpeq (2 + int (length (compStmt jmb stmt1))) #
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2016
            compStmt jmb stmt1 @ Goto (1 + int (length (compStmt jmb stmt2))) #
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2017
            compStmt jmb stmt2" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2018
  and "f1.0"=comb_nil and "f2.0" = "pushST [PrimT Boolean]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2019
  and "f3.0"="compTpExpr jmb G expr \<box> popST 2 \<box> compTpStmt jmb G stmt1 \<box>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2020
            nochangeST \<box> compTpStmt jmb G stmt2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2021
  in bc_mt_corresp_comb_inside)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2022
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2023
  apply (rule_tac T="(PrimT Boolean)" in bc_mt_corresp_LitPush)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2024
  apply (simp (no_asm_simp) add: start_sttp_resp_def)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2025
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2026
apply (drule_tac "bc1.0"="[LitPush (Bool False)]" and "bc2.0" = "compExpr jmb expr"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2027
  and "bc3.0"="Ifcmpeq (2 + int (length (compStmt jmb stmt1))) #
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2028
            compStmt jmb stmt1 @ Goto (1 + int (length (compStmt jmb stmt2))) #
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2029
            compStmt jmb stmt2" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2030
  and "f1.0"="pushST [PrimT Boolean]" and "f2.0" = "compTpExpr jmb G expr"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2031
  and "f3.0"="popST 2 \<box> compTpStmt jmb G stmt1 \<box>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2032
            nochangeST \<box> compTpStmt jmb G stmt2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2033
  in bc_mt_corresp_comb_inside)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2034
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2035
  apply (simp (no_asm_simp)  add: pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2036
  apply (rule  wt_method_compTpExpr_corresp) apply assumption+ 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2037
      apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2038
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2039
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2040
apply (drule_tac "bc1.0" = "[LitPush (Bool False)] @ compExpr jmb expr" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2041
    and inst = "Ifcmpeq (2 + int (length (compStmt jmb stmt1)))" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2042
  and "bc3.0" = "compStmt jmb stmt1 @ Goto (1 + int (length (compStmt jmb stmt2))) #
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2043
            compStmt jmb stmt2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2044
  and "f1.0"="pushST [PrimT Boolean] \<box> compTpExpr jmb G expr" and "f2.0" = "popST 2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2045
  and "f3.0"="compTpStmt jmb G stmt1 \<box> nochangeST \<box> compTpStmt jmb G stmt2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2046
  in bc_mt_corresp_comb_wt_instr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2047
  apply (simp (no_asm_simp) add: length_compTpExpr)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2048
  apply (simp (no_asm_simp) add: start_sttp_resp_comb)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2049
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2050
    (* wt_instr *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2051
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2052
  apply (rule_tac ts="PrimT Boolean" and ts'="PrimT Boolean" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2053
    and ST=ST and LT=LT 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2054
    in wt_instr_Ifcmpeq)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2055
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2056
  apply (simp (no_asm_simp) only: int_outside_right nat_int, simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2057
  apply (simp (no_asm_simp) only: int_outside_right nat_int, simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2058
    (* current pc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2059
  apply (simp add: length_compTpExpr pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2060
  apply (simp only: compTpExpr_LT_ST) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2061
    (* Suc pc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2062
  apply (simp add: length_compTpExpr pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2063
  apply (simp add: popST_def start_sttp_resp_comb)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2064
    (* jump goal *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2065
  apply (simp (no_asm_simp) only: int_outside_right nat_int, simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2066
  apply (simp add: length_compTpExpr pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2067
  apply (simp add: popST_def start_sttp_resp_comb length_compTpStmt)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2068
  apply (simp only: compTpStmt_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2069
  apply (simp add: nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2070
    (* check_type *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2071
  apply (subgoal_tac "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2072
    (mt_sttp_flatten (f' (ST, LT)) ! length ([LitPush (Bool False)] @ compExpr jmb expr)) = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2073
    (Some (PrimT Boolean # PrimT Boolean # ST, LT))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2074
  apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2075
  apply (simp (no_asm_simp)) apply (rule trans, rule mt_sttp_flatten_comb_length) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2076
    apply (rule HOL.refl) apply (simp (no_asm_simp) add: length_compTpExpr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2077
    apply (simp (no_asm_simp) add: length_compTpExpr pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2078
    apply (simp only: compTpExpr_LT_ST_rewr) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2079
    (* contracting\<dots> *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2080
  apply (rule contracting_popST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2081
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2082
apply (drule_tac 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2083
  "bc1.0"="[LitPush (Bool False)] @ compExpr jmb expr @ 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2084
           [Ifcmpeq (2 + int (length (compStmt jmb stmt1)))] " 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2085
  and "bc2.0" = "compStmt jmb stmt1"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2086
  and "bc3.0"="Goto (1 + int (length (compStmt jmb stmt2))) # compStmt jmb stmt2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2087
  and "f1.0"="pushST [PrimT Boolean] \<box> compTpExpr jmb G expr \<box> popST 2" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2088
  and "f2.0" = "compTpStmt jmb G stmt1"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2089
  and "f3.0"="nochangeST \<box> compTpStmt jmb G stmt2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2090
  in bc_mt_corresp_comb_inside)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2091
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2092
  apply (simp (no_asm_simp) add: pushST_def popST_def compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2093
  apply (simp only: compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2094
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2095
  apply (simp (no_asm_simp) add: length_compTpExpr)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2096
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2097
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2098
apply (drule_tac "bc1.0" = "[LitPush (Bool False)] @ compExpr jmb expr @ [Ifcmpeq (2 + int (length (compStmt jmb stmt1)))] @ compStmt jmb stmt1" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2099
    and inst = "Goto (1 + int (length (compStmt jmb stmt2)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2100
  and "bc3.0" = "compStmt jmb stmt2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2101
  and "f1.0"="pushST [PrimT Boolean] \<box> compTpExpr jmb G expr \<box> popST 2 \<box> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2102
              compTpStmt jmb G stmt1" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2103
  and "f2.0" = "nochangeST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2104
  and "f3.0"="compTpStmt jmb G stmt2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2105
  in bc_mt_corresp_comb_wt_instr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2106
  apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2107
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2108
  apply (rule wt_instr_Goto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2109
  apply (simp (no_asm_simp) only: int_outside_right nat_int, simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2110
  apply (simp (no_asm_simp) only: int_outside_right nat_int, simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2111
    (* \<dots> ! nat (int pc + i) = \<dots> ! pc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2112
  apply (simp (no_asm_simp) only: int_outside_right nat_int, simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2113
  apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2114
  apply (simp (no_asm_simp) add: pushST_def popST_def nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2115
  apply (simp only: compTpExpr_LT_ST compTpStmt_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2116
  apply (simp (no_asm_simp) add: pushST_def popST_def nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2117
  apply (simp only: compTpExpr_LT_ST compTpStmt_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2118
  apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2119
  apply (simp add: length_compTpExpr length_compTpStmt)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2120
  apply (rule contracting_nochangeST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2121
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2122
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2123
apply (drule_tac 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2124
  "bc1.0"= "[LitPush (Bool False)] @ compExpr jmb expr @ 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2125
            [Ifcmpeq (2 + int (length (compStmt jmb stmt1)))] @ 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2126
            compStmt jmb stmt1 @ [Goto (1 + int (length (compStmt jmb stmt2)))]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2127
  and "bc2.0" = "compStmt jmb stmt2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2128
  and "bc3.0"="[]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2129
  and "f1.0"="pushST [PrimT Boolean] \<box> compTpExpr jmb G expr \<box> popST 2 \<box> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2130
              compTpStmt jmb G stmt1 \<box> nochangeST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2131
  and "f2.0" = "compTpStmt jmb G stmt2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2132
  and "f3.0"="comb_nil"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2133
  in bc_mt_corresp_comb_inside)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2134
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2135
  apply (simp (no_asm_simp) add: pushST_def popST_def nochangeST_def compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2136
  apply (simp only: compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2137
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2138
  apply (simp only: compTpStmt_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2139
  apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2140
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2141
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2142
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2143
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2144
(* Loop *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2145
apply (intro allI impI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2146
apply (simp (no_asm_simp) only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2147
apply (drule Loop_invers, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2148
apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2149
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2150
apply (subgoal_tac "bc_mt_corresp bc' f' (ST, LT) (comp G) rT (length LT) 0")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2151
prefer 2 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2152
apply (rule bc_mt_corresp_zero) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2153
  apply (simp (no_asm_simp) add: length_compTpStmt length_compTpExpr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2154
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2155
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2156
apply (drule_tac "bc1.0"="[]" and "bc2.0" = "[LitPush (Bool False)]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2157
  and "bc3.0"="compExpr jmb expr @ Ifcmpeq (2 + int (length (compStmt jmb stmt))) #
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2158
            compStmt jmb stmt @ 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2159
            [Goto (-2 + (- int (length (compStmt jmb stmt)) - int (length (compExpr jmb expr))))]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2160
  and "f1.0"=comb_nil and "f2.0" = "pushST [PrimT Boolean]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2161
  and "f3.0"="compTpExpr jmb G expr \<box> popST 2 \<box> compTpStmt jmb G stmt \<box> nochangeST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2162
  in bc_mt_corresp_comb_inside)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2163
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2164
  apply (rule_tac T="(PrimT Boolean)" in bc_mt_corresp_LitPush)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2165
  apply (simp (no_asm_simp) add: start_sttp_resp_def)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2166
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2167
apply (drule_tac "bc1.0"="[LitPush (Bool False)]" and "bc2.0" = "compExpr jmb expr"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2168
  and "bc3.0"="Ifcmpeq (2 + int (length (compStmt jmb stmt))) #
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2169
            compStmt jmb stmt @ 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2170
            [Goto (-2 + (- int (length (compStmt jmb stmt)) - int (length (compExpr jmb expr))))]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2171
  and "f1.0"="pushST [PrimT Boolean]" and "f2.0" = "compTpExpr jmb G expr"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2172
  and "f3.0"="popST 2 \<box> compTpStmt jmb G stmt \<box> nochangeST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2173
  in bc_mt_corresp_comb_inside)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2174
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2175
  apply (simp (no_asm_simp)  add: pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2176
  apply (rule  wt_method_compTpExpr_corresp) apply assumption+ 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2177
      apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2178
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2179
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2180
apply (drule_tac "bc1.0" = "[LitPush (Bool False)] @ compExpr jmb expr" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2181
    and inst = "Ifcmpeq (2 + int (length (compStmt jmb stmt)))" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2182
  and "bc3.0" = "compStmt jmb stmt @ 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2183
       [Goto (-2 + (- int (length (compStmt jmb stmt)) - int (length (compExpr jmb expr))))]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2184
  and "f1.0"="pushST [PrimT Boolean] \<box> compTpExpr jmb G expr" and "f2.0" = "popST 2"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2185
  and "f3.0"="compTpStmt jmb G stmt \<box> nochangeST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2186
  in bc_mt_corresp_comb_wt_instr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2187
  apply (simp (no_asm_simp) add: length_compTpExpr)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2188
  apply (simp (no_asm_simp) add: start_sttp_resp_comb)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2189
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2190
    (* wt_instr *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2191
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2192
  apply (rule_tac ts="PrimT Boolean" and ts'="PrimT Boolean" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2193
    and ST=ST and LT=LT 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2194
    in wt_instr_Ifcmpeq)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2195
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2196
  apply (simp (no_asm_simp) only: int_outside_right nat_int, simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2197
  apply (simp (no_asm_simp) only: int_outside_right nat_int, simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2198
    (* current pc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2199
  apply (simp add: length_compTpExpr pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2200
  apply (simp only: compTpExpr_LT_ST) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2201
    (* Suc pc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2202
  apply (simp add: length_compTpExpr pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2203
  apply (simp add: popST_def start_sttp_resp_comb)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2204
    (* jump goal *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2205
  apply (simp (no_asm_simp) only: int_outside_right nat_int, simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2206
  apply (simp add: length_compTpExpr pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2207
  apply (simp add: popST_def start_sttp_resp_comb length_compTpStmt)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2208
  apply (simp only: compTpStmt_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2209
  apply (simp add: nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2210
    (* check_type *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2211
  apply (subgoal_tac "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2212
    (mt_sttp_flatten (f' (ST, LT)) ! length ([LitPush (Bool False)] @ compExpr jmb expr)) = 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2213
    (Some (PrimT Boolean # PrimT Boolean # ST, LT))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2214
  apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2215
  apply (simp (no_asm_simp)) apply (rule trans, rule mt_sttp_flatten_comb_length) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2216
    apply (rule HOL.refl) apply (simp (no_asm_simp) add: length_compTpExpr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2217
    apply (simp (no_asm_simp) add: length_compTpExpr pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2218
    apply (simp only: compTpExpr_LT_ST_rewr) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2219
    (* contracting\<dots> *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2220
  apply (rule contracting_popST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2221
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2222
apply (drule_tac 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2223
  "bc1.0"="[LitPush (Bool False)] @ compExpr jmb expr @ 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2224
           [Ifcmpeq (2 + int (length (compStmt jmb stmt)))] " 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2225
  and "bc2.0" = "compStmt jmb stmt"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2226
  and "bc3.0"="[Goto (-2 + (- int (length (compStmt jmb stmt)) - int (length (compExpr jmb expr))))]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2227
  and "f1.0"="pushST [PrimT Boolean] \<box> compTpExpr jmb G expr \<box> popST 2" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2228
  and "f2.0" = "compTpStmt jmb G stmt"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2229
  and "f3.0"="nochangeST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2230
  in bc_mt_corresp_comb_inside)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2231
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2232
  apply (simp (no_asm_simp) add: pushST_def popST_def compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2233
  apply (simp only: compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2234
  apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2235
  apply (simp (no_asm_simp) add: length_compTpExpr)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2236
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2237
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2238
apply (drule_tac "bc1.0" = "[LitPush (Bool False)] @ compExpr jmb expr @ [Ifcmpeq (2 + int (length (compStmt jmb stmt)))] @ compStmt jmb stmt" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2239
    and inst = "Goto (-2 + (- int (length (compStmt jmb stmt)) - int (length (compExpr jmb expr))))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2240
  and "bc3.0" = "[]"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2241
  and "f1.0"="pushST [PrimT Boolean] \<box> compTpExpr jmb G expr \<box> popST 2 \<box> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2242
              compTpStmt jmb G stmt" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2243
  and "f2.0" = "nochangeST"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2244
  and "f3.0"="comb_nil"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2245
  in bc_mt_corresp_comb_wt_instr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2246
  apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt)+ 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2247
  apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2248
  apply (rule wt_instr_Goto)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2249
  apply (simp (no_asm_simp) add: nat_canonify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2250
  apply (simp (no_asm_simp) add: nat_canonify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2251
    (* \<dots> ! nat (int pc + i) = \<dots> ! pc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2252
  apply (simp (no_asm_simp) add: nat_canonify)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2253
  apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2254
  apply (simp (no_asm_simp) add: pushST_def popST_def nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2255
  apply (simp only: compTpExpr_LT_ST compTpStmt_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2256
  apply (simp (no_asm_simp) only: int_outside_right nat_int)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2257
  apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2258
  apply (simp only: compTpExpr_LT_ST compTpStmt_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2259
  apply (simp (no_asm_simp) add: pushST_def popST_def nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2260
  apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2261
  apply (simp only: compTpExpr_LT_ST compTpStmt_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2262
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2263
  apply (simp add: length_compTpExpr length_compTpStmt) (* check_type *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2264
    apply (simp add: pushST_def popST_def compTpExpr_LT_ST compTpStmt_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2265
  apply (rule contracting_nochangeST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2266
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2267
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2268
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2269
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2270
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2271
  (**********************************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2272
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2273
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2274
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2275
lemma wt_method_compTpInit_corresp: "\<lbrakk> jmb = (pns,lvars,blk,res); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2276
  wf_java_mdecl G C ((mn, pTs), rT, jmb); mxr = length LT;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2277
  length LT = (length pns) + (length lvars) + 1;  vn \<in> set (map fst lvars);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2278
  bc = (compInit jmb (vn,ty)); f = (compTpInit jmb (vn,ty));
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2279
  is_type G ty \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2280
  \<Longrightarrow> bc_mt_corresp bc f (ST, LT) (comp G) rT mxr (length bc)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2281
apply (simp add: compInit_def compTpInit_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2282
apply (rule_tac "bc1.0"="[load_default_val ty]" and "bc2.0"="[Store (index jmb vn)]" 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2283
  in bc_mt_corresp_comb) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2284
  apply simp+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2285
  apply (simp add: load_default_val_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2286
   apply (rule typeof_default_val [THEN exE]) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2287
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2288
  apply (rule bc_mt_corresp_LitPush_CT) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2289
    apply (simp add: comp_is_type)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2290
apply (simp add: pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2291
  apply (rule bc_mt_corresp_Store_init)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2292
  apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2293
  apply (rule index_length_lvars [THEN conjunct2])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2294
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2295
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2296
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2297
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2298
lemma wt_method_compTpInitLvars_corresp_aux [rule_format (no_asm)]: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2299
  \<forall> lvars_pre lvars0 ST LT.
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2300
  jmb = (pns,lvars0,blk,res) \<and>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2301
  lvars0 = (lvars_pre @ lvars) \<and>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2302
  length LT = (length pns) + (length lvars0) + 1 \<and>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2303
  wf_java_mdecl G C ((mn, pTs), rT, jmb)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2304
 \<longrightarrow> bc_mt_corresp (compInitLvars jmb lvars) (compTpInitLvars jmb lvars) (ST, LT) (comp G) rT 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2305
       (length LT) (length (compInitLvars jmb lvars))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2306
apply (induct lvars)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2307
apply (simp add: compInitLvars_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2308
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2309
apply (intro strip, (erule conjE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2310
apply (subgoal_tac "\<exists> vn ty. a = (vn, ty)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2311
  prefer 2 apply (simp (no_asm_simp)) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2312
  apply ((erule exE)+, simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2313
apply (drule_tac x="lvars_pre @ [a]" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2314
apply (drule_tac x="lvars0" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2315
apply (simp (no_asm_simp) add: compInitLvars_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2316
apply (rule_tac "bc1.0"="compInit jmb a" and "bc2.0"="compInitLvars jmb list"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2317
  in bc_mt_corresp_comb)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2318
apply (simp (no_asm_simp) add: compInitLvars_def)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2319
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2320
apply (rule_tac vn=vn and ty=ty in wt_method_compTpInit_corresp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2321
apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2322
apply (simp (no_asm_simp))+ 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2323
apply (simp add: wf_java_mdecl_def)	(* is_type G ty *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2324
apply (simp add: compTpInit_def storeST_def pushST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2325
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2326
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2327
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2328
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2329
lemma wt_method_compTpInitLvars_corresp: "\<lbrakk> jmb = (pns,lvars,blk,res); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2330
  wf_java_mdecl G C ((mn, pTs), rT, jmb);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2331
  length LT = (length pns) + (length lvars) + 1; mxr = (length LT);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2332
  bc = (compInitLvars jmb lvars); f= (compTpInitLvars jmb lvars) \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2333
  \<Longrightarrow> bc_mt_corresp bc f (ST, LT) (comp G) rT mxr (length bc)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2334
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2335
apply (subgoal_tac "bc_mt_corresp (compInitLvars (pns, lvars, blk, res) lvars)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2336
        (compTpInitLvars (pns, lvars, blk, res) lvars) (ST, LT) (TranslComp.comp G) rT
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2337
        (length LT) (length (compInitLvars (pns, lvars, blk, res) lvars))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2338
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2339
apply (rule_tac lvars_pre="[]" in wt_method_compTpInitLvars_corresp_aux)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2340
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2341
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2342
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2343
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2344
  (**********************************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2345
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2346
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2347
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2348
lemma wt_method_comp_wo_return: "\<lbrakk> wf_prog wf_java_mdecl G;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2349
  wf_java_mdecl G C ((mn, pTs), rT, jmb); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2350
  bc = compInitLvars jmb lvars @ compStmt jmb blk @ compExpr jmb res;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2351
  jmb = (pns,lvars,blk,res); 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2352
  f = (compTpInitLvars jmb lvars \<box> compTpStmt jmb G blk \<box> compTpExpr jmb G res);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2353
  sttp = (start_ST, start_LT C pTs (length lvars));
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2354
  li = (length (inited_LT C pTs lvars))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2355
  \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2356
\<Longrightarrow> bc_mt_corresp bc f sttp (comp G) rT  li (length bc)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2357
apply (subgoal_tac "\<exists> E. (E = (local_env G C (mn, pTs) pns lvars) \<and> E \<turnstile> blk \<surd> \<and> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2358
                         (\<exists>T. E\<turnstile>res::T \<and> G\<turnstile>T\<preceq>rT))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2359
   apply (erule exE, (erule conjE)+)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2360
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2361
apply (rule bc_mt_corresp_comb) apply (rule HOL.refl)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2362
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2363
  (* InitLvars *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2364
apply (rule wt_method_compTpInitLvars_corresp) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2365
   apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2366
   apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2367
   apply (simp (no_asm_simp) add: start_LT_def) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2368
       apply (rule wf_java_mdecl_length_pTs_pns, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2369
   apply (simp (no_asm_simp) only: start_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2370
   apply (simp (no_asm_simp) add: inited_LT_def)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2371
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2372
apply (rule bc_mt_corresp_comb) apply (rule HOL.refl)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2373
   apply (simp (no_asm_simp) add: compTpInitLvars_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2374
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2375
     (* stmt *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2376
apply (simp only: compTpInitLvars_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2377
apply (subgoal_tac "(Suc (length pTs + length lvars)) = (length (inited_LT C pTs lvars))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2378
   prefer 2 apply (simp (no_asm_simp) add: inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2379
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2380
apply (rule_tac s=blk in wt_method_compTpStmt_corresp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2381
   apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2382
   apply (simp only:)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2383
   apply (simp (no_asm_simp) add: is_inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2384
   apply (simp only:)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2385
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2386
     (* expr *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2387
apply (simp only: compTpInitLvars_LT_ST compTpStmt_LT_ST is_inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2388
apply (subgoal_tac "(Suc (length pTs + length lvars)) = (length (inited_LT C pTs lvars))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2389
   prefer 2 apply (simp (no_asm_simp) add: inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2390
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2391
apply (rule_tac ex=res in wt_method_compTpExpr_corresp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2392
   apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2393
   apply (simp only:)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2394
   apply (simp (no_asm_simp) add: is_inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2395
   apply (simp only:)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2396
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2397
     (* start_sttp_resp *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2398
apply (simp add: start_sttp_resp_comb)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2399
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2400
  (* subgoal *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2401
apply (simp add: wf_java_mdecl_def local_env_def) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2402
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2403
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2404
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2405
  (**********************************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2406
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2407
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2408
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2409
lemma check_type_start: "\<lbrakk> wf_mhead cG (mn, pTs) rT; is_class cG C\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2410
  \<Longrightarrow> check_type cG (length start_ST) (Suc (length pTs + mxl))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2411
              (OK (Some (start_ST, start_LT C pTs mxl)))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2412
apply (simp add: check_type_def wf_mhead_def start_ST_def start_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2413
apply (simp add: check_type_simps)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2414
apply (simp only: list_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2415
apply (auto simp: err_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2416
apply (subgoal_tac "set (replicate mxl Err) \<subseteq>  {Err}")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2417
apply blast
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2418
apply (rule subset_replicate)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2419
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2420
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2421
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2422
lemma wt_method_comp_aux: "\<lbrakk>   bc' = bc @ [Return]; f' = (f \<box> nochangeST);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2423
  bc_mt_corresp bc f sttp0 cG rT (1+length pTs+mxl) (length bc);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2424
  start_sttp_resp_cons f';
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2425
  sttp0 = (start_ST, start_LT C pTs mxl);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2426
  mxs = max_ssize (mt_of (f' sttp0));
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2427
  wf_mhead cG (mn, pTs) rT; is_class cG C;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2428
  sttp_of (f sttp0) = (T # ST, LT);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2429
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2430
  check_type cG mxs (1+length pTs+mxl) (OK (Some (T # ST, LT))) \<longrightarrow>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2431
  wt_instr_altern Return cG rT (mt_of (f' sttp0)) mxs (1+length pTs+mxl) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2432
         (Suc (length bc)) empty_et (length bc)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2433
\<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2434
\<Longrightarrow> wt_method_altern cG C pTs rT mxs mxl bc' empty_et (mt_of (f' sttp0))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2435
apply (subgoal_tac "check_type cG (length start_ST) (Suc (length pTs + mxl))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2436
              (OK (Some (start_ST, start_LT C pTs mxl)))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2437
apply (subgoal_tac "check_type cG mxs (1+length pTs+mxl) (OK (Some (T # ST, LT)))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2438
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2439
apply (simp add: wt_method_altern_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2440
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2441
  (* length (.. f ..) = length bc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2442
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2443
apply (simp add: bc_mt_corresp_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2444
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2445
  (* check_bounded *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2446
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2447
apply (simp add: bc_mt_corresp_def split_beta check_bounded_def) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2448
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2449
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2450
apply (subgoal_tac "pc < (length bc) \<or> pc = length bc")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2451
  apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2452
    (* case  pc < length bc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2453
    apply (subgoal_tac "(bc' ! pc) = (bc ! pc)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2454
    apply (simp add: wt_instr_altern_def eff_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2455
      (* subgoal *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2456
    apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2457
    (* case  pc = length bc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2458
    apply (subgoal_tac "(bc' ! pc) = Return")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2459
    apply (simp add: wt_instr_altern_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2460
      (* subgoal *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2461
    apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2462
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2463
    (* subgoal pc < length bc \<or> pc = length bc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2464
apply arith
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2465
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2466
  (* wt_start *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2467
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2468
apply (simp add: wt_start_def start_sttp_resp_cons_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2469
  apply (drule_tac x=sttp0 in spec) apply (erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2470
  apply (simp add: mt_sttp_flatten_def start_ST_def start_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2471
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2472
  (* wt_instr *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2473
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2474
apply (subgoal_tac "pc < (length bc) \<or> pc = length bc")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2475
apply (erule disjE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2476
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2477
  (* pc < (length bc) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2478
apply (simp (no_asm_use) add: bc_mt_corresp_def mt_sttp_flatten_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2479
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2480
apply (drule mp, assumption)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2481
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2482
apply (drule spec, drule mp, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2483
apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2484
apply (simp (no_asm_simp) add: comb_def split_beta nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2485
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2486
  (* pc = length bc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2487
apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2488
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2489
  (* subgoal pc < (length bc) \<or> pc = length bc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2490
apply arith
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2491
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2492
  (* subgoals *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2493
apply (simp (no_asm_use) add: bc_mt_corresp_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2494
apply (subgoal_tac "check_type cG (length (fst sttp0)) (Suc (length pTs + mxl))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2495
         (OK (Some sttp0))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2496
apply ((erule conjE)+, drule mp, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2497
apply (simp add: nth_append)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2498
apply (simp (no_asm_simp) add: comb_def nochangeST_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2499
apply (simp (no_asm_simp))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2500
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2501
apply (rule check_type_start, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2502
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2503
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2504
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2505
lemma wt_instr_Return: "\<lbrakk>fst f ! pc = Some (T # ST, LT); (G \<turnstile> T \<preceq> rT); pc < max_pc;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2506
  check_type (TranslComp.comp G) mxs mxr (OK (Some (T # ST, LT)))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2507
  \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2508
  \<Longrightarrow> wt_instr_altern Return (comp G) rT  (mt_of f) mxs mxr max_pc empty_et pc"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2509
  apply (case_tac "(mt_of f ! pc)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2510
  apply (simp  add: wt_instr_altern_def eff_def norm_eff_def app_def)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2511
  apply (drule sym)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2512
  apply (simp add: comp_widen xcpt_app_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2513
  done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2514
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2515
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2516
theorem wt_method_comp: "
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2517
  \<lbrakk> wf_java_prog G; (C, D, fds, mths) \<in> set G; jmdcl \<in> set mths;
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2518
  jmdcl = ((mn,pTs), rT, jmb);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2519
  mt = (compTpMethod G C jmdcl);
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2520
  (mxs, mxl, bc, et) = mtd_mb (compMethod G C jmdcl) \<rbrakk>
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2521
  \<Longrightarrow> wt_method (comp G) C pTs rT mxs mxl bc et mt"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2522
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2523
  (* show statement for wt_method_altern *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2524
apply (rule wt_method_altern_wt_method)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2525
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2526
apply (subgoal_tac "wf_java_mdecl G C jmdcl")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2527
apply (subgoal_tac "wf_mhead G (mn, pTs) rT")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2528
apply (subgoal_tac "is_class G C")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2529
apply (subgoal_tac "\<forall> jmb. \<exists> pns lvars blk res. jmb = (pns, lvars, blk, res)")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2530
   apply (drule_tac x=jmb in spec, (erule exE)+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2531
apply (subgoal_tac "\<exists> E. (E = (local_env G C (mn, pTs) pns lvars) \<and> E \<turnstile> blk \<surd> \<and> 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2532
                         (\<exists>T. E\<turnstile>res::T \<and> G\<turnstile>T\<preceq>rT))")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2533
   apply (erule exE, (erule conjE)+)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2534
apply (simp add: compMethod_def compTpMethod_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2535
apply (rule_tac T=T and LT="inited_LT C pTs lvars" and ST=start_ST in wt_method_comp_aux)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2536
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2537
  (* bc *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2538
apply (simp only: append_assoc [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2539
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2540
  (* comb *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2541
apply (simp only: comb_assoc [THEN sym])
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2542
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2543
  (* bc_corresp *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2544
apply (rule wt_method_comp_wo_return)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2545
  apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2546
  apply (simp (no_asm_use) only: append_assoc)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2547
  apply (rule HOL.refl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2548
  apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2549
  apply (simp (no_asm_simp) add: inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2550
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2551
  (* start_sttp_resp *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2552
apply (simp add: start_sttp_resp_cons_comb_cons_r)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2553
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2554
  (* wf_mhead / is_class *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2555
apply (simp add: wf_mhead_def comp_is_type)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2556
apply (simp add: comp_is_class)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2557
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2558
  (* sttp_of .. = (T # ST, LT) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2559
apply (simp (no_asm_simp) add: compTpInitLvars_LT_ST compTpExpr_LT_ST compTpStmt_LT_ST is_inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2560
apply (subgoal_tac "(snd (compTpInitLvars (pns, lvars, blk, res) lvars
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2561
                              (start_ST, start_LT C pTs (length lvars))))
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2562
                = (start_ST, inited_LT C pTs lvars)") 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2563
   prefer 2 apply (rule compTpInitLvars_LT_ST) apply (rule HOL.refl) apply assumption
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2564
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2565
apply (subgoal_tac "(snd (compTpStmt (pns, lvars, blk, res) G blk
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2566
                       (start_ST, inited_LT C pTs lvars))) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2567
                = (start_ST, inited_LT C pTs lvars)") 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2568
   prefer 2 apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2569
   apply (rule compTpStmt_LT_ST) apply (rule HOL.refl) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2570
   apply (simp only:)+ apply (simp (no_asm_simp) add: is_inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2571
apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2572
apply (rule compTpExpr_LT_ST) apply (rule HOL.refl) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2573
   apply (simp only:)+ apply (simp (no_asm_simp) add: is_inited_LT_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2574
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2575
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2576
   (* Return *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2577
apply (intro strip)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2578
apply (rule_tac T=T and ST=start_ST and LT="inited_LT C pTs lvars" in wt_instr_Return)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2579
apply (simp (no_asm_simp) add: nth_append 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2580
  length_compTpInitLvars length_compTpStmt length_compTpExpr)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2581
apply (simp only: compTpInitLvars_LT_ST compTpStmt_LT_ST compTpExpr_LT_ST 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2582
  nochangeST_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2583
apply (simp only: is_inited_LT_def compTpStmt_LT_ST compTpExpr_LT_ST)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2584
apply (simp (no_asm_simp))+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2585
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2586
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2587
  (* subgoal \<exists> E. \<dots> *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2588
apply (simp add: wf_java_mdecl_def local_env_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2589
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2590
  (* subgoal jmb = (\<dots>) *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2591
apply (simp only: split_paired_All, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2592
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2593
  (* subgoal is_class / wf_mhead / wf_java_mdecl *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2594
apply (rule methd [THEN conjunct2]) apply assumption+ apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2595
apply (rule wf_prog_wf_mhead, assumption+) apply (simp only:)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2596
apply (rule wf_java_prog_wf_java_mdecl, assumption+)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2597
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2598
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2599
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2600
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2601
  (**********************************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2602
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2603
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2604
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2605
lemma comp_set_ms: "(C, D, fs, cms)\<in>set (comp G) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2606
  \<Longrightarrow> \<exists> ms. (C, D, fs, ms) \<in>set G   \<and> cms = map (compMethod G C) ms"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2607
by (auto simp: comp_def compClass_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2608
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2609
lemma method_body_source: "\<lbrakk> wf_prog wf_mb G; is_class G C;  method (comp G, C) sig = Some (D, rT, cmb) \<rbrakk>  
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2610
  \<Longrightarrow>  (\<exists> mb. method (G, C) sig = Some (D, rT, mb))"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2611
apply (simp add: comp_method_eq comp_method_result_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2612
apply (case_tac "method (G, C) sig")
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2613
apply auto
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2614
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2615
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2616
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2617
  (* MAIN THEOREM: 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2618
  Methodtype computed by comp is correct for bytecode generated by compTp *)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2619
theorem wt_prog_comp: "wf_java_prog G  \<Longrightarrow> wt_jvm_prog (comp G) (compTp G)"
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2620
apply (simp add: wf_prog_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2621
apply (subgoal_tac "wf_java_prog G") prefer 2 apply (simp add: wf_prog_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2622
apply (simp (no_asm_simp) add: wf_prog_def wt_jvm_prog_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2623
apply (simp add:  comp_unique comp_wf_syscls wf_cdecl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2624
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2625
apply (frule comp_set_ms)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2626
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2627
apply (drule bspec, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2628
apply (simp add: comp_wf_fdecl)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2629
apply (simp add: wf_mdecl_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2630
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2631
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2632
apply (rule ballI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2633
apply (subgoal_tac "\<exists> sig rT mb. x = (sig, rT, mb)") prefer 2 apply (case_tac x, simp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2634
apply (erule exE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2635
apply (simp (no_asm_simp) add: compMethod_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2636
apply (erule conjE)+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2637
apply (drule_tac x="(sig, rT, mb)" in bspec) apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2638
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2639
apply (simp add: comp_wf_mhead)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2640
apply (rule_tac mn="fst sig" and pTs="snd sig" in wt_method_comp)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2641
  apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2642
  apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2643
apply (simp (no_asm_simp) add: compTp_def)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2644
apply (simp (no_asm_simp) add: compMethod_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2645
apply (frule WellForm.methd) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2646
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2647
apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2648
apply (simp add: compMethod_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2649
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2650
apply (rule conjI)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2651
apply (rule unique_map_fst [THEN iffD1]) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2652
  apply (simp (no_asm_simp) add: compMethod_def split_beta) apply simp
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2653
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2654
apply clarify
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2655
apply (rule conjI) apply (simp add: comp_is_class)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2656
apply (rule conjI) apply (simp add: comp_subcls)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2657
apply (simp add: compMethod_def split_beta)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2658
apply (intro strip) 
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2659
  apply (drule_tac x=x in bspec, assumption, drule_tac x="D'" in spec, drule_tac x="rT'" in spec)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2660
  apply (erule exE)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2661
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2662
apply (frule method_body_source) apply assumption+
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2663
apply (drule mp, assumption)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2664
apply (simp add: comp_widen)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2665
done
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2666
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2667
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2668
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2669
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2670
  (**********************************************************************************)
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2671
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2672
declare split_paired_All [simp add]
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2673
declare split_paired_Ex [simp add]
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2674
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2675
2950128b8206 First checkin of compiler
streckem
parents:
diff changeset
  2676
end