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