author | kleing |
Fri, 16 Nov 2001 23:02:58 +0100 | |
changeset 12230 | b06cc3834ee5 |
parent 11701 | 3d51fbf81c17 |
child 12516 | d09d0f160888 |
permissions | -rw-r--r-- |
10592 | 1 |
(* Title: HOL/BCV/JVM.thy |
2 |
ID: $Id$ |
|
3 |
Author: Tobias Nipkow |
|
4 |
Copyright 2000 TUM |
|
5 |
||
6 |
*) |
|
7 |
||
10637 | 8 |
header "Kildall for the JVM" |
10592 | 9 |
|
11229 | 10 |
theory JVM = Kildall + JVMType + Opt + Product + Typing_Framework_err + |
11 |
StepMono + BVSpec: |
|
10592 | 12 |
|
13 |
constdefs |
|
14 |
exec :: "jvm_prog \<Rightarrow> nat \<Rightarrow> ty \<Rightarrow> instr list \<Rightarrow> nat \<Rightarrow> state \<Rightarrow> state" |
|
15 |
"exec G maxs rT bs == err_step (\<lambda>pc. app (bs!pc) G maxs rT) (\<lambda>pc. step (bs!pc) G)" |
|
16 |
||
17 |
kiljvm :: "jvm_prog => nat => nat => ty => instr list => state list => state list" |
|
18 |
"kiljvm G maxs maxr rT bs == |
|
11298 | 19 |
kildall (JVMType.le G maxs maxr) (JVMType.sup G maxs maxr) (exec G maxs rT bs) (\<lambda>pc. succs (bs!pc) pc)" |
10592 | 20 |
|
10637 | 21 |
wt_kil :: "jvm_prog \<Rightarrow> cname \<Rightarrow> ty list \<Rightarrow> ty \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> instr list \<Rightarrow> bool" |
22 |
"wt_kil G C pTs rT mxs mxl ins == |
|
23 |
bounded (\<lambda>n. succs (ins!n) n) (size ins) \<and> 0 < size ins \<and> |
|
24 |
(let first = Some ([],(OK (Class C))#((map OK pTs))@(replicate mxl Err)); |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11299
diff
changeset
|
25 |
start = OK first#(replicate (size ins - 1) (OK None)); |
10637 | 26 |
result = kiljvm G mxs (1+size pTs+mxl) rT ins start |
27 |
in \<forall>n < size ins. result!n \<noteq> Err)" |
|
28 |
||
29 |
wt_jvm_prog_kildall :: "jvm_prog => bool" |
|
30 |
"wt_jvm_prog_kildall G == |
|
31 |
wf_prog (\<lambda>G C (sig,rT,(maxs,maxl,b)). wt_kil G C (snd sig) rT maxs maxl b) G" |
|
10592 | 32 |
|
33 |
||
34 |
lemma special_ex_swap_lemma [iff]: |
|
35 |
"(? X. (? n. X = A n & P n) & Q X) = (? n. Q(A n) & P n)" |
|
36 |
by blast |
|
37 |
||
10630 | 38 |
lemmas [iff del] = not_None_eq |
39 |
||
10592 | 40 |
theorem exec_pres_type: |
41 |
"[| wf_prog wf_mb S |] ==> |
|
42 |
pres_type (exec S maxs rT bs) (size bs) (states S maxs maxr)" |
|
43 |
apply (unfold pres_type_def list_def step_def JVM_states_unfold) |
|
44 |
apply (clarify elim!: option_map_in_optionI lift_in_errI) |
|
45 |
apply (simp add: exec_def err_step_def lift_def split: err.split) |
|
46 |
apply (simp add: step_def option_map_def split: option.splits) |
|
47 |
apply clarify |
|
48 |
apply (case_tac "bs!p") |
|
49 |
||
12230 | 50 |
apply (fastsimp simp add: not_Err_eq dest: subsetD nth_mem) |
10637 | 51 |
apply fastsimp |
12230 | 52 |
apply (fastsimp simp add: not_None_eq typeof_empty_is_type) |
10637 | 53 |
apply fastsimp |
12230 | 54 |
apply (fastsimp dest: field_fields fields_is_type) |
10637 | 55 |
apply fastsimp |
56 |
apply fastsimp |
|
10592 | 57 |
defer |
10637 | 58 |
apply fastsimp |
59 |
apply fastsimp |
|
60 |
apply fastsimp |
|
61 |
apply fastsimp |
|
62 |
apply fastsimp |
|
63 |
apply fastsimp |
|
64 |
apply fastsimp |
|
65 |
apply fastsimp |
|
66 |
apply fastsimp |
|
10592 | 67 |
|
10637 | 68 |
(* Invoke *) |
12230 | 69 |
apply (clarsimp simp add: Un_subset_iff) |
10630 | 70 |
apply (drule method_wf_mdecl, assumption+) |
10592 | 71 |
apply (simp add: wf_mdecl_def wf_mhead_def) |
72 |
done |
|
73 |
||
10630 | 74 |
|
75 |
lemmas [iff] = not_None_eq |
|
76 |
||
77 |
||
10592 | 78 |
theorem exec_mono: |
79 |
"wf_prog wf_mb G ==> |
|
10812
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
80 |
mono (JVMType.le G maxs maxr) (exec G maxs rT bs) (size bs) (states G maxs maxr)" |
10592 | 81 |
apply (unfold mono_def) |
82 |
apply clarify |
|
83 |
apply (unfold lesub_def) |
|
84 |
apply (case_tac t) |
|
85 |
apply (simp add: JVM_le_unfold Err.le_def exec_def err_step_def lift_def) |
|
86 |
apply (case_tac s) |
|
87 |
apply (simp add: JVM_le_unfold Err.le_def exec_def err_step_def lift_def) |
|
88 |
apply (simp add: JVM_le_convert exec_def err_step_def lift_def) |
|
89 |
apply (simp add: JVM_le_unfold Err.le_def exec_def err_step_def lift_def) |
|
90 |
apply (rule conjI) |
|
91 |
apply clarify |
|
92 |
apply (rule step_mono, assumption+) |
|
93 |
apply (rule impI) |
|
94 |
apply (erule contrapos_nn) |
|
95 |
apply (rule app_mono, assumption+) |
|
96 |
done |
|
97 |
||
98 |
theorem semilat_JVM_slI: |
|
10812
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
99 |
"[| wf_prog wf_mb G |] ==> semilat (JVMType.sl G maxs maxr)" |
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
100 |
apply (unfold JVMType.sl_def stk_esl_def reg_sl_def) |
10592 | 101 |
apply (rule semilat_opt) |
102 |
apply (rule err_semilat_Product_esl) |
|
103 |
apply (rule err_semilat_upto_esl) |
|
104 |
apply (rule err_semilat_JType_esl, assumption+) |
|
105 |
apply (rule err_semilat_eslI) |
|
106 |
apply (rule semilat_Listn_sl) |
|
107 |
apply (rule err_semilat_JType_esl, assumption+) |
|
108 |
done |
|
109 |
||
110 |
lemma sl_triple_conv: |
|
10812
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
111 |
"JVMType.sl G maxs maxr == |
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
112 |
(states G maxs maxr, JVMType.le G maxs maxr, JVMType.sup G maxs maxr)" |
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
113 |
by (simp (no_asm) add: states_def JVMType.le_def JVMType.sup_def) |
10592 | 114 |
|
115 |
||
116 |
theorem is_bcv_kiljvm: |
|
117 |
"[| wf_prog wf_mb G; bounded (\<lambda>pc. succs (bs!pc) pc) (size bs) |] ==> |
|
10812
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
118 |
is_bcv (JVMType.le G maxs maxr) Err (exec G maxs rT bs) (\<lambda>pc. succs (bs!pc) pc) |
10592 | 119 |
(size bs) (states G maxs maxr) (kiljvm G maxs maxr rT bs)" |
120 |
apply (unfold kiljvm_def sl_triple_conv) |
|
121 |
apply (rule is_bcv_kildall) |
|
122 |
apply (simp (no_asm) add: sl_triple_conv [symmetric]) |
|
123 |
apply (force intro!: semilat_JVM_slI dest: wf_acyclic simp add: symmetric sl_triple_conv) |
|
124 |
apply (simp (no_asm) add: JVM_le_unfold) |
|
125 |
apply (blast intro!: order_widen wf_converse_subcls1_impl_acc_subtype |
|
126 |
dest: wf_subcls1 wf_acyclic) |
|
127 |
apply (simp add: JVM_le_unfold) |
|
128 |
apply (erule exec_pres_type) |
|
129 |
apply assumption |
|
130 |
apply (erule exec_mono) |
|
131 |
done |
|
132 |
||
10637 | 133 |
|
134 |
theorem wt_kil_correct: |
|
135 |
"[| wt_kil G C pTs rT maxs mxl bs; wf_prog wf_mb G; |
|
10592 | 136 |
is_class G C; \<forall>x \<in> set pTs. is_type G x |] |
137 |
==> \<exists>phi. wt_method G C pTs rT maxs mxl bs phi" |
|
138 |
proof - |
|
139 |
let ?start = "OK (Some ([],(OK (Class C))#((map OK pTs))@(replicate mxl Err))) |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11299
diff
changeset
|
140 |
#(replicate (size bs - 1) (OK None))" |
10592 | 141 |
|
10637 | 142 |
assume wf: "wf_prog wf_mb G" |
143 |
assume isclass: "is_class G C" |
|
144 |
assume istype: "\<forall>x \<in> set pTs. is_type G x" |
|
145 |
||
146 |
assume "wt_kil G C pTs rT maxs mxl bs" |
|
147 |
then obtain maxr r where |
|
148 |
bounded: "bounded (\<lambda>pc. succs (bs!pc) pc) (size bs)" and |
|
149 |
result: "r = kiljvm G maxs maxr rT bs ?start" and |
|
150 |
success: "\<forall>n < size bs. r!n \<noteq> Err" and |
|
151 |
instrs: "0 < size bs" and |
|
152 |
maxr: "maxr = Suc (length pTs + mxl)" |
|
153 |
by (unfold wt_kil_def) simp |
|
10592 | 154 |
|
155 |
{ fix pc |
|
156 |
have "succs (bs!pc) pc \<noteq> []" |
|
157 |
by (cases "bs!pc") auto |
|
158 |
} |
|
159 |
||
160 |
hence non_empty: "non_empty (\<lambda>pc. succs (bs!pc) pc)" |
|
161 |
by (unfold non_empty_def) blast |
|
162 |
||
163 |
from wf bounded |
|
164 |
have bcv: |
|
10812
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
165 |
"is_bcv (JVMType.le G maxs maxr) Err (exec G maxs rT bs) (\<lambda>pc. succs (bs!pc) pc) |
10592 | 166 |
(size bs) (states G maxs maxr) (kiljvm G maxs maxr rT bs)" |
167 |
by (rule is_bcv_kiljvm) |
|
168 |
||
169 |
{ fix l x |
|
170 |
have "set (replicate l x) \<subseteq> {x}" |
|
171 |
by (cases "0 < l") simp+ |
|
172 |
} note subset_replicate = this |
|
173 |
||
174 |
from istype |
|
175 |
have "set pTs \<subseteq> types G" |
|
176 |
by auto |
|
177 |
||
10834 | 178 |
hence "OK ` set pTs \<subseteq> err (types G)" |
10592 | 179 |
by auto |
180 |
||
181 |
with instrs maxr isclass |
|
182 |
have "?start \<in> list (length bs) (states G maxs maxr)" |
|
183 |
apply (unfold list_def JVM_states_unfold) |
|
184 |
apply simp |
|
185 |
apply (rule conjI) |
|
186 |
apply (simp add: Un_subset_iff) |
|
187 |
apply (rule_tac B = "{Err}" in subset_trans) |
|
188 |
apply (simp add: subset_replicate) |
|
189 |
apply simp |
|
190 |
apply (rule_tac B = "{OK None}" in subset_trans) |
|
191 |
apply (simp add: subset_replicate) |
|
192 |
apply simp |
|
193 |
done |
|
194 |
||
195 |
with bcv success result |
|
196 |
have |
|
197 |
"\<exists>ts\<in>list (length bs) (states G maxs maxr). |
|
10812
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
198 |
?start <=[JVMType.le G maxs maxr] ts \<and> |
11299 | 199 |
wt_step (JVMType.le G maxs maxr) Err (exec G maxs rT bs) (\<lambda>pc. succs (bs ! pc) pc) ts" |
10592 | 200 |
by (unfold is_bcv_def) auto |
201 |
||
202 |
then obtain phi' where |
|
203 |
l: "phi' \<in> list (length bs) (states G maxs maxr)" and |
|
10812
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
204 |
s: "?start <=[JVMType.le G maxs maxr] phi'" and |
11299 | 205 |
w: "wt_step (JVMType.le G maxs maxr) Err (exec G maxs rT bs) (\<lambda>pc. succs (bs ! pc) pc) phi'" |
10592 | 206 |
by blast |
207 |
||
208 |
hence dynamic: |
|
209 |
"dynamic_wt (sup_state_opt G) (exec G maxs rT bs) (\<lambda>pc. succs (bs ! pc) pc) phi'" |
|
210 |
by (simp add: dynamic_wt_def exec_def JVM_le_Err_conv) |
|
211 |
||
212 |
from s |
|
10812
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
213 |
have le: "JVMType.le G maxs maxr (?start ! 0) (phi'!0)" |
10592 | 214 |
by (drule_tac p=0 in le_listD) (simp add: lesub_def)+ |
215 |
||
216 |
from l |
|
217 |
have l: "size phi' = size bs" |
|
218 |
by simp |
|
219 |
||
220 |
with instrs w |
|
221 |
have "phi' ! 0 \<noteq> Err" |
|
11299 | 222 |
by (unfold wt_step_def) simp |
10592 | 223 |
|
224 |
with instrs l |
|
225 |
have phi0: "OK (map ok_val phi' ! 0) = phi' ! 0" |
|
10812
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
226 |
by (clarsimp simp add: not_Err_eq) |
10592 | 227 |
|
228 |
from l bounded |
|
229 |
have "bounded (\<lambda>pc. succs (bs ! pc) pc) (length phi')" |
|
230 |
by simp |
|
231 |
||
232 |
with dynamic non_empty |
|
233 |
have "static_wt (sup_state_opt G) (\<lambda>pc. app (bs!pc) G maxs rT) (\<lambda>pc. step (bs!pc) G) |
|
234 |
(\<lambda>pc. succs (bs!pc) pc) (map ok_val phi')" |
|
235 |
by (auto intro: dynamic_imp_static simp add: exec_def) |
|
236 |
||
237 |
with instrs l le bounded |
|
238 |
have "wt_method G C pTs rT maxs mxl bs (map ok_val phi')" |
|
239 |
apply (unfold wt_method_def static_wt_def) |
|
240 |
apply simp |
|
241 |
apply (rule conjI) |
|
242 |
apply (unfold wt_start_def) |
|
243 |
apply (rule JVM_le_convert [THEN iffD1]) |
|
244 |
apply (simp (no_asm) add: phi0) |
|
245 |
apply clarify |
|
246 |
apply (erule allE, erule impE, assumption) |
|
247 |
apply (elim conjE) |
|
248 |
apply (clarsimp simp add: lesub_def wt_instr_def) |
|
249 |
apply (unfold bounded_def) |
|
250 |
apply blast |
|
251 |
done |
|
252 |
||
253 |
thus ?thesis by blast |
|
254 |
qed |
|
255 |
||
10651 | 256 |
|
10657 | 257 |
(* there's still one easy, and one nontrivial (but provable) sorry in here *) |
258 |
(* |
|
10651 | 259 |
theorem wt_kil_complete: |
260 |
"[| wt_method G C pTs rT maxs mxl bs phi; wf_prog wf_mb G; |
|
261 |
length phi = length bs; is_class G C; \<forall>x \<in> set pTs. is_type G x |] |
|
262 |
==> wt_kil G C pTs rT maxs mxl bs" |
|
263 |
proof - |
|
264 |
assume wf: "wf_prog wf_mb G" |
|
265 |
assume isclass: "is_class G C" |
|
266 |
assume istype: "\<forall>x \<in> set pTs. is_type G x" |
|
267 |
assume length: "length phi = length bs" |
|
268 |
||
269 |
assume "wt_method G C pTs rT maxs mxl bs phi" |
|
270 |
then obtain |
|
271 |
instrs: "0 < length bs" and |
|
272 |
wt_start: "wt_start G C pTs mxl phi" and |
|
273 |
wt_ins: "\<forall>pc. pc < length bs \<longrightarrow> |
|
274 |
wt_instr (bs ! pc) G rT phi maxs (length bs) pc" |
|
275 |
by (unfold wt_method_def) simp |
|
276 |
||
277 |
let ?succs = "\<lambda>pc. succs (bs!pc) pc" |
|
278 |
let ?step = "\<lambda>pc. step (bs!pc) G" |
|
279 |
let ?app = "\<lambda>pc. app (bs!pc) G maxs rT" |
|
280 |
||
281 |
from wt_ins |
|
282 |
have bounded: "bounded ?succs (size bs)" |
|
283 |
by (unfold wt_instr_def bounded_def) blast |
|
284 |
||
285 |
from wt_ins |
|
286 |
have "static_wt (sup_state_opt G) ?app ?step ?succs phi" |
|
287 |
apply (unfold static_wt_def wt_instr_def lesub_def) |
|
288 |
apply (simp (no_asm) only: length) |
|
289 |
apply blast |
|
290 |
done |
|
291 |
||
292 |
with bounded |
|
293 |
have "dynamic_wt (sup_state_opt G) (err_step ?app ?step) ?succs (map OK phi)" |
|
294 |
by - (erule static_imp_dynamic, simp add: length) |
|
295 |
||
296 |
hence dynamic: |
|
297 |
"dynamic_wt (sup_state_opt G) (exec G maxs rT bs) ?succs (map OK phi)" |
|
298 |
by (unfold exec_def) |
|
299 |
||
300 |
let ?maxr = "1+size pTs+mxl" |
|
301 |
||
302 |
from wf bounded |
|
303 |
have is_bcv: |
|
10812
ead84e90bfeb
merged semilattice orders with <=' from Convert.thy (now defined in JVMType.thy)
kleing
parents:
10657
diff
changeset
|
304 |
"is_bcv (JVMType.le G maxs ?maxr) Err (exec G maxs rT bs) ?succs |
10651 | 305 |
(size bs) (states G maxs ?maxr) (kiljvm G maxs ?maxr rT bs)" |
306 |
by (rule is_bcv_kiljvm) |
|
307 |
||
308 |
let ?start = "OK (Some ([],(OK (Class C))#((map OK pTs))@(replicate mxl Err))) |
|
11701
3d51fbf81c17
sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents:
11299
diff
changeset
|
309 |
#(replicate (size bs - 1) (OK None))" |
10651 | 310 |
|
311 |
{ fix l x |
|
312 |
have "set (replicate l x) \<subseteq> {x}" |
|
313 |
by (cases "0 < l") simp+ |
|
314 |
} note subset_replicate = this |
|
315 |
||
316 |
from istype |
|
317 |
have "set pTs \<subseteq> types G" |
|
318 |
by auto |
|
319 |
||
10834 | 320 |
hence "OK ` set pTs \<subseteq> err (types G)" |
10651 | 321 |
by auto |
322 |
||
323 |
with instrs isclass |
|
324 |
have start: |
|
325 |
"?start \<in> list (length bs) (states G maxs ?maxr)" |
|
326 |
apply (unfold list_def JVM_states_unfold) |
|
327 |
apply simp |
|
328 |
apply (rule conjI) |
|
329 |
apply (simp add: Un_subset_iff) |
|
330 |
apply (rule_tac B = "{Err}" in subset_trans) |
|
331 |
apply (simp add: subset_replicate) |
|
332 |
apply simp |
|
333 |
apply (rule_tac B = "{OK None}" in subset_trans) |
|
334 |
apply (simp add: subset_replicate) |
|
335 |
apply simp |
|
336 |
done |
|
337 |
||
338 |
let ?phi = "map OK phi" |
|
339 |
||
340 |
have 1: "?phi \<in> list (length bs) (states G maxs ?maxr)" sorry |
|
341 |
||
10657 | 342 |
have 2: "?start <=[le G maxs ?maxr] ?phi" |
343 |
proof - |
|
344 |
{ fix n |
|
345 |
from wt_start |
|
346 |
have "G \<turnstile> ok_val (?start!0) <=' phi!0" |
|
347 |
by (simp add: wt_start_def) |
|
348 |
moreover |
|
349 |
from instrs length |
|
350 |
have "0 < length phi" by simp |
|
351 |
ultimately |
|
352 |
have "le G maxs ?maxr (?start!0) (?phi!0)" |
|
353 |
by (simp add: JVM_le_Err_conv Err.le_def lesub_def) |
|
354 |
moreover |
|
355 |
{ fix n' |
|
356 |
have "le G maxs ?maxr (OK None) (?phi!n)" |
|
357 |
by (auto simp add: JVM_le_Err_conv Err.le_def lesub_def |
|
358 |
split: err.splits) |
|
359 |
hence "[| n = Suc n'; n < length ?start |] |
|
360 |
==> le G maxs ?maxr (?start!n) (?phi!n)" |
|
361 |
by simp |
|
362 |
} |
|
363 |
ultimately |
|
364 |
have "n < length ?start ==> le G maxs ?maxr (?start!n) (?phi!n)" |
|
365 |
by - (cases n, blast+) |
|
366 |
} |
|
367 |
thus ?thesis sorry |
|
368 |
qed |
|
10651 | 369 |
|
370 |
from dynamic |
|
11299 | 371 |
have "wt_step (le G maxs ?maxr) Err (exec G maxs rT bs) ?succs ?phi" |
10651 | 372 |
by (simp add: dynamic_wt_def JVM_le_Err_conv) |
373 |
||
374 |
with start 1 2 is_bcv |
|
375 |
have "\<forall>p. p < length bs \<longrightarrow> kiljvm G maxs ?maxr rT bs ?start ! p \<noteq> Err" |
|
376 |
by (unfold is_bcv_def) blast |
|
377 |
||
378 |
with bounded instrs |
|
379 |
show "wt_kil G C pTs rT maxs mxl bs" |
|
380 |
by (unfold wt_kil_def) simp |
|
381 |
qed |
|
10657 | 382 |
*) |
10651 | 383 |
|
10637 | 384 |
lemma is_type_pTs: |
385 |
"[| wf_prog wf_mb G; (C,S,fs,mdecls) \<in> set G; (sig,rT,code) \<in> set mdecls; |
|
386 |
t \<in> set (snd sig) |] |
|
387 |
==> is_type G t" |
|
388 |
proof - |
|
389 |
assume "wf_prog wf_mb G" |
|
390 |
"(C,S,fs,mdecls) \<in> set G" |
|
391 |
"(sig,rT,code) \<in> set mdecls" |
|
392 |
hence "wf_mdecl wf_mb G C (sig,rT,code)" |
|
393 |
by (unfold wf_prog_def wf_cdecl_def) auto |
|
394 |
hence "\<forall>t \<in> set (snd sig). is_type G t" |
|
395 |
by (unfold wf_mdecl_def wf_mhead_def) auto |
|
396 |
moreover |
|
397 |
assume "t \<in> set (snd sig)" |
|
398 |
ultimately |
|
399 |
show ?thesis by blast |
|
400 |
qed |
|
401 |
||
402 |
||
403 |
theorem jvm_kildall_correct: |
|
404 |
"wt_jvm_prog_kildall G ==> \<exists>Phi. wt_jvm_prog G Phi" |
|
405 |
proof - |
|
406 |
assume wtk: "wt_jvm_prog_kildall G" |
|
407 |
||
408 |
then obtain wf_mb where |
|
409 |
wf: "wf_prog wf_mb G" |
|
410 |
by (auto simp add: wt_jvm_prog_kildall_def) |
|
411 |
||
412 |
let ?Phi = "\<lambda>C sig. let (C,rT,(maxs,maxl,ins)) = the (method (G,C) sig) in |
|
413 |
SOME phi. wt_method G C (snd sig) rT maxs maxl ins phi" |
|
414 |
||
415 |
{ fix C S fs mdecls sig rT code |
|
416 |
assume "(C,S,fs,mdecls) \<in> set G" "(sig,rT,code) \<in> set mdecls" |
|
417 |
with wf |
|
418 |
have "method (G,C) sig = Some (C,rT,code) \<and> is_class G C \<and> (\<forall>t \<in> set (snd sig). is_type G t)" |
|
419 |
by (simp add: methd is_type_pTs) |
|
420 |
} note this [simp] |
|
421 |
||
422 |
from wtk |
|
423 |
have "wt_jvm_prog G ?Phi" |
|
424 |
apply (unfold wt_jvm_prog_def wt_jvm_prog_kildall_def wf_prog_def wf_cdecl_def) |
|
425 |
apply clarsimp |
|
426 |
apply (drule bspec, assumption) |
|
427 |
apply (unfold wf_mdecl_def) |
|
428 |
apply clarsimp |
|
429 |
apply (drule bspec, assumption) |
|
430 |
apply clarsimp |
|
431 |
apply (drule wt_kil_correct [OF _ wf]) |
|
432 |
apply (auto intro: someI) |
|
433 |
done |
|
434 |
||
435 |
thus ?thesis by blast |
|
436 |
qed |
|
437 |
||
10592 | 438 |
end |