author | wenzelm |
Tue, 25 Jul 2000 00:06:46 +0200 | |
changeset 9436 | 62bb04ab4b01 |
parent 8442 | 96023903c2df |
child 9594 | 42d11e0a7a8b |
permissions | -rw-r--r-- |
8011 | 1 |
(* Title: HOL/MicroJava/BV/Correct.ML |
2 |
ID: $Id$ |
|
3 |
Author: Cornelia Pusch |
|
4 |
Copyright 1999 Technische Universitaet Muenchen |
|
5 |
*) |
|
6 |
||
7 |
(** sup_heap **) |
|
8 |
||
9 |
Goalw [hext_def] |
|
10 |
"hp x = None \\<longrightarrow> hp \\<le>| (hp((newref hp) \\<mapsto> obj))"; |
|
11 |
by (asm_full_simp_tac (simpset() addsimps []) 1); |
|
12 |
by (Clarify_tac 1); |
|
13 |
bd newref_None 1; |
|
14 |
back(); |
|
15 |
by (asm_full_simp_tac (simpset() addsimps []) 1); |
|
16 |
qed_spec_mp "sup_heap_newref"; |
|
17 |
||
18 |
||
19 |
Goalw [hext_def] |
|
8048 | 20 |
"hp a = Some (C,od') \\<longrightarrow> hp \\<le>| (hp(a \\<mapsto> (C,od)))"; |
8011 | 21 |
by (asm_full_simp_tac (simpset() addsimps []) 1); |
22 |
qed_spec_mp "sup_heap_update_value"; |
|
23 |
||
24 |
||
25 |
(** approx_val **) |
|
26 |
||
27 |
Goalw [approx_val_def] |
|
28 |
"approx_val G hp x None"; |
|
29 |
by (Asm_full_simp_tac 1); |
|
30 |
qed_spec_mp "approx_val_None"; |
|
31 |
||
32 |
||
33 |
Goalw [approx_val_def] |
|
34 |
"approx_val G hp Null (Some(RefT x))"; |
|
35 |
by(Simp_tac 1); |
|
36 |
by (fast_tac (claset() addIs widen.intrs) 1); |
|
37 |
qed_spec_mp "approx_val_Null"; |
|
38 |
||
39 |
||
40 |
Goal |
|
41 |
"\\<lbrakk> wf_prog wt G \\<rbrakk> \ |
|
42 |
\\\<Longrightarrow> approx_val G hp v (Some T) \\<longrightarrow> G\\<turnstile> T\\<preceq>T' \\<longrightarrow> approx_val G hp v (Some T')"; |
|
8442
96023903c2df
case_tac now subsumes both boolean and datatype cases;
wenzelm
parents:
8423
diff
changeset
|
43 |
by (case_tac "T" 1); |
8011 | 44 |
by (Asm_simp_tac 1); |
45 |
by (fast_tac (claset() addIs [conf_widen] addss (simpset()addsimps[approx_val_def])) 1); |
|
46 |
qed_spec_mp "approx_val_imp_approx_val_assConvertible"; |
|
47 |
||
48 |
||
49 |
Goal |
|
50 |
"approx_val G hp val at \\<longrightarrow> hp \\<le>| hp' \\<longrightarrow> approx_val G hp' val at"; |
|
51 |
by (asm_full_simp_tac (simpset() setloop (split_tac [option.split]) |
|
52 |
addsimps [approx_val_def]) 1); |
|
53 |
by(blast_tac (claset() addIs [conf_hext]) 1); |
|
54 |
qed_spec_mp "approx_val_imp_approx_val_sup_heap"; |
|
55 |
||
56 |
Goal |
|
57 |
"\\<lbrakk> hp a = Some obj' ; G,hp\\<turnstile> v\\<Colon>\\<preceq>T ; obj_ty obj = obj_ty obj' \\<rbrakk> \ |
|
58 |
\\\<Longrightarrow>G,(hp(a\\<mapsto>obj))\\<turnstile> v\\<Colon>\\<preceq>T"; |
|
8442
96023903c2df
case_tac now subsumes both boolean and datatype cases;
wenzelm
parents:
8423
diff
changeset
|
59 |
by (case_tac "v" 1); |
8011 | 60 |
by (auto_tac (claset() , simpset() addsimps [obj_ty_def,conf_def] addsplits [option.split])); |
61 |
qed_spec_mp "approx_val_imp_approx_val_heap_update"; |
|
62 |
||
63 |
||
64 |
Goal |
|
8023 | 65 |
"wf_prog wt G \\<Longrightarrow> approx_val G h val us \\<longrightarrow> G \\<turnstile> us <=o us' \\<longrightarrow> approx_val G h val us'"; |
8011 | 66 |
by (asm_simp_tac (simpset() addsimps [sup_PTS_eq,approx_val_def] addsplits [option.split,val_.split,ty.split]) 1); |
67 |
by(blast_tac (claset() addIs [conf_widen]) 1); |
|
68 |
qed_spec_mp "approx_val_imp_approx_val_sup"; |
|
69 |
||
70 |
||
8119 | 71 |
Goalw [approx_loc_def,list_all2_def] |
8023 | 72 |
"\\<lbrakk> wf_prog wt G; approx_loc G hp loc LT; idx < length LT ; val = loc ! idx ; G \\<turnstile> LT ! idx <=o at\\<rbrakk> \ |
8011 | 73 |
\\\<Longrightarrow> approx_val G hp val at"; |
74 |
by (fast_tac (claset() addIs [approx_val_imp_approx_val_sup] addss (simpset() addsimps |
|
8119 | 75 |
[split_def,all_set_conv_all_nth])) 1); |
8011 | 76 |
qed "approx_loc_imp_approx_val_sup"; |
77 |
||
78 |
||
79 |
(** approx_loc **) |
|
80 |
||
8119 | 81 |
Goalw [approx_loc_def] |
8011 | 82 |
"approx_loc G hp (s#xs) (l#ls) = \ |
8119 | 83 |
\ (approx_val G hp s l \\<and> approx_loc G hp xs ls)"; |
84 |
by (Simp_tac 1); |
|
8011 | 85 |
qed "approx_loc_Cons"; |
8119 | 86 |
AddIffs [approx_loc_Cons]; |
8011 | 87 |
|
88 |
||
8119 | 89 |
Goalw [approx_stk_def,approx_loc_def,list_all2_def] |
8011 | 90 |
"\\<lbrakk> wf_prog wt G \\<rbrakk> \ |
91 |
\\\<Longrightarrow> (\\<forall>tt'\\<in>set (zip tys_n ts). tt' \\<in> widen G) \\<longrightarrow> \ |
|
92 |
\ length tys_n = length ts \\<longrightarrow> approx_stk G hp s tys_n \\<longrightarrow> approx_loc G hp s (map Some ts)"; |
|
93 |
by (force_tac (claset() addIs [approx_val_imp_approx_val_assConvertible], simpset() |
|
94 |
addsimps [all_set_conv_all_nth,split_def]) 1); |
|
95 |
qed_spec_mp "assConv_approx_stk_imp_approx_loc"; |
|
96 |
||
97 |
||
8119 | 98 |
Goalw [approx_loc_def,list_all2_def] |
8011 | 99 |
"\\<forall> lvars. approx_loc G hp lvars lt \\<longrightarrow> hp \\<le>| hp' \\<longrightarrow> approx_loc G hp' lvars lt"; |
8442
96023903c2df
case_tac now subsumes both boolean and datatype cases;
wenzelm
parents:
8423
diff
changeset
|
100 |
by (case_tac "lt" 1); |
8011 | 101 |
by (Asm_simp_tac 1); |
102 |
by (force_tac (claset() addIs [approx_val_imp_approx_val_sup_heap], |
|
103 |
simpset() addsimps [neq_Nil_conv]) 1); |
|
104 |
qed_spec_mp "approx_loc_imp_approx_loc_sup_heap"; |
|
105 |
||
106 |
||
8119 | 107 |
Goalw [sup_loc_def,approx_loc_def,list_all2_def] |
8023 | 108 |
"wf_prog wt G \\<Longrightarrow> approx_loc G hp lvars lt \\<longrightarrow> G \\<turnstile> lt <=l lt' \\<longrightarrow> approx_loc G hp lvars lt'"; |
8011 | 109 |
by (auto_tac (claset() , simpset() addsimps [all_set_conv_all_nth,split_def])); |
110 |
by (auto_tac (claset() addEs [approx_val_imp_approx_val_sup] , simpset())); |
|
111 |
qed_spec_mp "approx_loc_imp_approx_loc_sup"; |
|
112 |
||
113 |
||
8119 | 114 |
Goalw [approx_loc_def,list_all2_def] |
8011 | 115 |
"\\<forall>loc idx x X. (approx_loc G hp loc LT) \\<longrightarrow> (approx_val G hp x X) \ |
116 |
\ \\<longrightarrow> (approx_loc G hp (loc[idx:=x]) (LT[idx:=X]))"; |
|
8288 | 117 |
by (fast_tac (claset() addDs [set_update_subset_insert RS subsetD] |
8011 | 118 |
addss (simpset() addsimps [zip_update])) 1); |
119 |
qed_spec_mp "approx_loc_imp_approx_loc_subst"; |
|
120 |
||
121 |
||
8119 | 122 |
Goalw [approx_loc_def,list_all2_def] |
8011 | 123 |
"\\<forall>L1 l2 L2. length l1=length L1 \ |
124 |
\ \\<longrightarrow> approx_loc G hp (l1@l2) (L1@L2) = (approx_loc G hp l1 L1 \\<and> approx_loc G hp l2 L2)"; |
|
8119 | 125 |
by(simp_tac (simpset() addcongs [conj_cong] addsimps [zip_append]) 1); |
126 |
by(Blast_tac 1); |
|
8011 | 127 |
qed_spec_mp "approx_loc_append"; |
128 |
||
129 |
||
130 |
(** approx_stk **) |
|
131 |
||
8119 | 132 |
Goalw [approx_stk_def,approx_loc_def,list_all2_def] |
8011 | 133 |
"approx_stk G hp (rev s) (rev t) = approx_stk G hp s t"; |
134 |
by (fast_tac (claset() addss (simpset() addsimps [zip_rev,rev_map RS sym])) 1); |
|
135 |
qed_spec_mp "approx_stk_rev_lem"; |
|
136 |
||
137 |
Goal |
|
138 |
"approx_stk G hp (rev s) t = approx_stk G hp s (rev t)"; |
|
139 |
by (fast_tac (claset() addIs [approx_stk_rev_lem RS subst] addss (simpset())) 1); |
|
140 |
qed_spec_mp "approx_stk_rev"; |
|
141 |
||
142 |
Goalw [approx_stk_def] |
|
143 |
"\\<forall> lvars. approx_stk G hp lvars lt \\<longrightarrow> hp \\<le>| hp' \\<longrightarrow> approx_stk G hp' lvars lt"; |
|
144 |
by (fast_tac (claset() addIs [approx_loc_imp_approx_loc_sup_heap]) 1); |
|
145 |
qed_spec_mp "approx_stk_imp_approx_stk_sup_heap"; |
|
146 |
||
147 |
||
148 |
Goalw [approx_stk_def] |
|
8023 | 149 |
"wf_prog wt G \\<Longrightarrow> approx_stk G hp lvars st \\<longrightarrow> G \\<turnstile> (map Some st) <=l (map Some st') \\<longrightarrow> approx_stk G hp lvars st'"; |
8011 | 150 |
by (fast_tac (claset() addIs [approx_loc_imp_approx_loc_sup]) 1); |
151 |
qed_spec_mp "approx_stk_imp_approx_stk_sup"; |
|
152 |
||
153 |
Goalw [approx_stk_def,approx_loc_def] |
|
154 |
"approx_stk G hp [] []"; |
|
8119 | 155 |
by (Simp_tac 1); |
8011 | 156 |
qed "approx_stk_Nil"; |
8119 | 157 |
AddIffs [approx_stk_Nil]; |
158 |
||
159 |
Goalw [approx_stk_def,approx_loc_def] |
|
160 |
"approx_stk G hp (x # stk) (S#ST) = (approx_val G hp x (Some S) \\<and> approx_stk G hp stk ST)"; |
|
161 |
by (Simp_tac 1); |
|
162 |
qed "approx_stk_Cons"; |
|
163 |
AddIffs [approx_stk_Cons]; |
|
164 |
||
165 |
Goalw [approx_stk_def,approx_loc_def] |
|
166 |
"approx_stk G hp stk (S#ST') = \ |
|
167 |
\ (\\<exists>s stk'. stk = s#stk' \\<and> approx_val G hp s (Some S) \\<and> approx_stk G hp stk' ST')"; |
|
168 |
by (asm_full_simp_tac (simpset() addsimps [list_all2_Cons2]) 1); |
|
169 |
qed "approx_stk_Cons_lemma"; |
|
170 |
AddIffs [approx_stk_Cons_lemma]; |
|
8011 | 171 |
|
172 |
||
173 |
Goalw [approx_stk_def,approx_loc_def] |
|
8119 | 174 |
"approx_stk G hp stk (S@ST') \ |
175 |
\ \\<Longrightarrow> (\\<exists>s stk'. stk = s@stk' \\<and> length s = length S \\<and> length stk' = length ST' \\<and> \ |
|
8011 | 176 |
\ approx_stk G hp s S \\<and> approx_stk G hp stk' ST')"; |
8119 | 177 |
by(asm_full_simp_tac (simpset() addsimps [list_all2_append2]) 1); |
8011 | 178 |
qed_spec_mp "approx_stk_append_lemma"; |
179 |
||
180 |
||
181 |
(** oconf **) |
|
182 |
||
183 |
Goalw [oconf_def,lconf_def] |
|
184 |
"\\<lbrakk> is_class G C; wf_prog wt G \\<rbrakk> \\<Longrightarrow> \ |
|
185 |
\G,h\\<turnstile> (C, map_of (map (\\<lambda>(f,fT).(f,default_val fT)) (fields(G,C))))\\<surd>"; |
|
186 |
by (asm_full_simp_tac (simpset() addsimps [map_of_map]) 1); |
|
187 |
by (force_tac (claset() addIs [defval_conf] |
|
188 |
addDs [map_of_SomeD,is_type_fields],simpset()) 1); |
|
189 |
qed "correct_init_obj"; |
|
190 |
||
191 |
||
192 |
Goalw [oconf_def,lconf_def] |
|
193 |
"\\<lbrakk> map_of (fields (G, oT)) FD = Some T ; G,hp\\<turnstile>v\\<Colon>\\<preceq>T ; \ |
|
194 |
\ G,hp\\<turnstile>(oT,fs)\\<surd> \\<rbrakk> \ |
|
195 |
\\\<Longrightarrow> G,hp\\<turnstile>(oT, fs(FD\\<mapsto>v))\\<surd>"; |
|
196 |
by (asm_full_simp_tac (simpset() addsplits [ty.split]) 1); |
|
197 |
qed_spec_mp "oconf_imp_oconf_field_update"; |
|
198 |
||
199 |
||
200 |
Goalw [oconf_def,lconf_def] |
|
201 |
"hp x = None \\<longrightarrow> G,hp\\<turnstile>obj\\<surd> \\<longrightarrow> G,hp\\<turnstile>obj'\\<surd> \ |
|
202 |
\ \\<longrightarrow> G,(hp(newref hp\\<mapsto>obj'))\\<turnstile>obj\\<surd>"; |
|
203 |
by (Asm_full_simp_tac 1); |
|
204 |
by (fast_tac (claset() addIs [conf_hext,sup_heap_newref]) 1); |
|
205 |
qed_spec_mp "oconf_imp_oconf_heap_newref"; |
|
206 |
||
207 |
Goalw [oconf_def,lconf_def] |
|
208 |
"hp a = Some obj' \\<longrightarrow> obj_ty obj' = obj_ty obj'' \\<longrightarrow> G,hp\\<turnstile>obj\\<surd> \ |
|
209 |
\ \\<longrightarrow> G,hp(a\\<mapsto>obj'')\\<turnstile>obj\\<surd>"; |
|
210 |
by (Asm_full_simp_tac 1); |
|
211 |
by (fast_tac (claset() addIs [approx_val_imp_approx_val_heap_update] addss (simpset())) 1); |
|
212 |
qed_spec_mp "oconf_imp_oconf_heap_update"; |
|
213 |
||
214 |
||
215 |
(** hconf **) |
|
216 |
||
217 |
||
8032 | 218 |
Goal "hp x = None \\<longrightarrow> G\\<turnstile>h hp\\<surd> \\<longrightarrow> G,hp\\<turnstile>obj\\<surd> \\<longrightarrow> G\\<turnstile>h hp(newref hp\\<mapsto>obj)\\<surd>"; |
8011 | 219 |
by (asm_full_simp_tac (simpset() addsplits [split_split] |
220 |
addsimps [hconf_def]) 1); |
|
221 |
by (fast_tac (claset()addIs[oconf_imp_oconf_heap_newref] addss (simpset())) 1); |
|
222 |
qed_spec_mp "hconf_imp_hconf_newref"; |
|
223 |
||
224 |
||
225 |
Goal "map_of (fields (G, oT)) (F, D) = Some T \\<and> hp oloc = Some(oT,fs) \\<and> \ |
|
8032 | 226 |
\ G,hp\\<turnstile>v\\<Colon>\\<preceq>T \\<and> G\\<turnstile>h hp\\<surd> \\<longrightarrow> G\\<turnstile>h hp(oloc \\<mapsto> (oT, fs((F,D)\\<mapsto>v)))\\<surd>"; |
8011 | 227 |
by (asm_full_simp_tac (simpset() addsimps [hconf_def]) 1); |
228 |
by (fast_tac (claset() addIs |
|
229 |
[oconf_imp_oconf_heap_update, oconf_imp_oconf_field_update] |
|
230 |
addss (simpset() addsimps [obj_ty_def])) 1); |
|
231 |
qed_spec_mp "hconf_imp_hconf_field_update"; |
|
232 |
||
233 |
||
234 |
(** correct_frames **) |
|
235 |
||
236 |
Delsimps [fun_upd_apply]; |
|
237 |
Goal |
|
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8032
diff
changeset
|
238 |
"\\<forall>rT C sig. correct_frames G hp phi rT sig frs \\<longrightarrow> \ |
8048 | 239 |
\ hp a = Some (C,od) \\<longrightarrow> map_of (fields (G, C)) fl = Some fd \\<longrightarrow> \ |
8011 | 240 |
\ G,hp\\<turnstile>v\\<Colon>\\<preceq>fd \ |
8048 | 241 |
\ \\<longrightarrow> correct_frames G (hp(a \\<mapsto> (C, od(fl\\<mapsto>v)))) phi rT sig frs"; |
8011 | 242 |
by (induct_tac "frs" 1); |
243 |
by (Asm_full_simp_tac 1); |
|
244 |
by (asm_full_simp_tac (simpset() addsimps [split_def,correct_frame_def]) 1); |
|
245 |
by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup_heap, |
|
246 |
approx_loc_imp_approx_loc_sup_heap, |
|
247 |
sup_heap_update_value] addss (simpset())) 1); |
|
248 |
qed_spec_mp "correct_frames_imp_correct_frames_field_update"; |
|
249 |
||
250 |
||
251 |
Goal |
|
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8032
diff
changeset
|
252 |
"\\<forall>rT C sig. hp x = None \\<longrightarrow> correct_frames G hp phi rT sig frs \\<and> \ |
8011 | 253 |
\ oconf G hp obj \ |
8045
816f566c414f
Fixed a problem with returning from the last frame.
nipkow
parents:
8032
diff
changeset
|
254 |
\ \\<longrightarrow> correct_frames G (hp(newref hp \\<mapsto> obj)) phi rT sig frs"; |
8011 | 255 |
by (induct_tac "frs" 1); |
256 |
by (asm_full_simp_tac (simpset() addsimps []) 1); |
|
257 |
by (asm_full_simp_tac (simpset() addsimps [split_def,correct_frame_def]) 1); |
|
258 |
by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup_heap, |
|
259 |
approx_loc_imp_approx_loc_sup_heap, |
|
260 |
hconf_imp_hconf_newref, |
|
261 |
sup_heap_newref] addss (simpset())) 1); |
|
262 |
qed_spec_mp "correct_frames_imp_correct_frames_newref"; |
|
263 |