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