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