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